home..

Git

Git Setup

global

git config --list --global to see all glocal git account git config --global user.name *** git config --global user.email *** Redo will override.

local

If you have a lot of git accounts, use the most frequently used one as global. Set up other local account inside the project folder. git config user.name *** git config user.email *** Local git account has higher priority, will override the global account.

Setting up a repo

From existing company one: git clone

Restore

git rm from commit git rm --catched from stage

Stash

A temporary drawer for unfinished versions git stash git stash list git stash apply 0

Undo changes

git checkout . git clean -f git revert git reset

Recommit

When you do something more right after you make a commit, you want to commit again, but it is unnecessary.
git commit --amend --no-edit to add new changes to the previous commit, not changing the previous comment.

Branches

Every task needs a new branch Naming convension: /-

git branch check your current branch and other branches git checkout -b feature1 open a new branch called feature1 git checkout feature1 go to feature1 branch

Merge
  1. git checkout master go to master branch
  2. git merge feature1 merge feature1 to master
Everyday work routine - first thing to do
  1. On master branch: git pull
  2. On your branch: git rebase master

Remote Repo

When kicking off in a company

git clone to clone source code and histories git remote --verbose or git remote -v to check remote url Now you are in your local master branch. But remote master doesn’t allow your local master to push. git checkout -b diana-17-sept to open your own branch

After you do something git branch -u <name> <branch> or just click “sync”. sync means pull and push

How to check remote changes git checkout master go to your local master git fetch check remote changes git pull sync with remote

You do something in your own branch git push <name> <branch> or click “sync”

Rebase

Same as MERGE in terms of result. Difference is MERGE shows a full tree, REBASE shows a clean tree.

For senior dev,interactive rebase for trimming branch git rebase -i HEAD~5

© 2023 Diana Wenjiao Liu   •  Powered by Soopr   •  Theme  Moonwalk