First, create and merge branches
1, View branch: git branch, listed a series of branches, with an asterisk is the current branch
2, create a branch: git branch <name>
3, handover branch: git checkout <name>
4, create a branch switching +: git checkout -b <name>
5, merging branches to the current branch: git merge <name>
6, delete the branch: git branch -d <name>
Second, merge conflicts
1, create a new branch feature1, modify content and submit
git checkout -b feature1
vi readme.txt (additional line of text in readme.txt file, ": wq" to save)
git add readme.txt
git commit -m "Add a row"
2, switch to the master branch, and submit content
git checkout master
vi readme.txt (add a line of new content in the readme.txt)
git add readme.txt
git commit -m "Add another line."
3, feature1 branch and merge the master branch, will merge conflict
git merge feature1
git status can use this command to view
4, merge conflict solution: manually modify the content inside readme.txt
vi readme.txt
git log --graph --pretty = oneline --abrrev-commit, merging branches can be seen in FIG.
Third, the branch management strategy
When switched to the master branch combined without Fast Forward Mode
git merge --no-ff -m "without fast forward" dev
Use this command to be able to see history merge, but if you do not use this command to see the history of merger news, but the content is the same after the merger it! ! !
Four, bug branch
When you work (dev branch) do half the time, your boss to let you fix a bug, but you half the job is not complete, we can not submit, then how to stop the work at hand and to repair bug it? You can work your "frozen" for some time, to create a new branch for bug fixes and then submit it to thaw. (Why not create branches directly modify the different branches of complementary interference is not it? Is submitted with the time of filing the branch do? See point 2)
1, git stash command sets the current working branch "frozen"
2, git status note, be sure to use this command to see whether the current work area is clean, only the work area is clean to be able to rest assured that the modifications
2, git checkout master switch to the upper branch in need of repair
3, git checkout -b issue-01 to create a new branch for bug fixes
4, after switching to the modified master branch and the branch combined issue-01
5, git checkout dev switch to your working branch
6, git stash list this time with the git status to see the work area is clean, because your work interval is put on ice, use this command to be able to see the project was put on ice
7, git stash pop this command can restore and delete the contents inside the stash, it splits the equivalent of two commands: apply the specified name git stash apply (to restore the contents of the stash, you can use git stash list to view the contents can be restored name) + git stash drop (delete the contents of the stash)
Fifth, to force the removal of a feature branch unincorporated branch
git branch -D <name> is the mandatory use -D delete, if the -d delete fail
Six people collaborate
1, view the remote library of information: git remote
2, view the remote library for more information: git remote -v
3, push to a remote repository: git push origin master (/ dev) where the origin is the name of the remote library, master or dev, and so you need to push the repository name