github(3)Git Branching
3.1 Git Branching - What a Branch Is
Git doesn't store data as a series of change sets or deltas, but instead as a series of snapshots.
Every directory root has a checksum number, every commit will point to a snapshot.
The default branch name is Git is master.As I initially make commits, you're given a master branch that points to the last commit you made. Every time you commit, it moves forward automatically.
When we create a new branch, that is doing so creates a new pointer for me to move around.
Create a branch
>git branch testing
In Git, a special pointer called HEAD will point to the local branch I am currently on.
Checkout a branch
>git checkout testing
This command will just move HEAD to point to the testing branch.
3.2 Git Branching - Basic Branching and Merging
Basic Branching
>git checkout -b issue53
Create a branch named issue53 and switched to this new branch.
Or
>git branch issue53
>git checkout issue53
Switch to master and merge the branch issue53
>git checkout master
>git merge issue53
Once we merge the branch back, we can delete the branch.
>git branch -d issue53
Basic Merging
Check out the branch we plan to merge our fix branch into.
>git checkout develop
Merge the fix branch into the develop
>git merge issue53
Basic Merge Conflicts
We may get conflict in this step.
CONFLICT(content): Merge conflict in xxxxx
Automatic merge failed; fix conflicts and then commit the result.
Check which file has conflict
>git status
I can directly use vim to merge the code. After that I use git add on each file to mark it as resolved.
>git add xxxx
Or I can use UI tool
>git mergetool
3.3 Git Branching - Branch Management
Branch Management
List all the branches
>git branch
To see the last commit on each branch
>git branch -v
There are 2 useful options. --merged and --no-merged
It will list all the branches merged to the current branch.
>git branch --merged
>git branch --no-merged
If a branch is not merged to current branch, we can not delete it with this command.
>git branch -d xxxx
We need to use command
>git branch -D xxxx
3.4 Git Branching - Branching Workflows
…snip…
3.5 Git Branching - Remote Branches
Pushing
The syntax will be >git push (remote) (branch)
>git push origin develop
Tracking Branches
This command will show all the branches, including the remotes
>git branch -a
Once I delete my branch, I need to delete the remote branch
>git push origin :branchName
3.6 Git Branching - Rebasing
…snip...
http://git-scm.com/book/en/Git-Branching-Rebasing
References:
http://git-scm.com/book/en/Git-Branching
http://git-scm.com/book/en/Git-Basics-Tagging
http://sillycat.iteye.com/blog/1423479
http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging
github(3)Git Branching
猜你喜欢
转载自sillycat.iteye.com/blog/1819574
今日推荐
周排行