[Reference:] https://segmentfault.com/q/1010000000181403
We generally do this: create a master branch remotely, and create a feature branch locally for each person. The daily workflow is as follows:
# go to own working branch $ git checkout my_work_branch Work .... # Commit the changes to the working branch $ git commit -a # go back to master branch $ git checkout master # Get the latest remote modification, no conflict will occur at this time $ git pull # go back to working branch $ git checkout my_work_branch # Use rebase to merge the changes of the trunk, if there is a conflict, resolve it at this time $ git rebase master # go back to master branch $ git checkout master # Merge the changes of the working branch without conflicts. $ git merge my_work_branch # commit to remote trunk $ git push
Create a branch: $ git branch mybranch Switch branches: $ git checkout mybranch Create and switch branches: $ git checkout -b mybranch