In the summary of Git learning (1), we got to know Git and are familiar with some common operations of Git. Today, we mainly summarize the branch management of Git. In the actual process of using Git, we should all develop based on branches (based on security considerations).
1. Create a new branch
git checkout -b branch name (equivalent to: git branch branch name dev; git checkout branch name dev)
2. View all branches
git branch (the main branch is called master)
3. Branch merge
After completing development based on the branch, we need to merge the branch into the master branch, using the following command:
First git branch master switches to the main branch master, and then git merge develops the branch dev (this is a fast forward mode, you can't see the merge information, another merge mode: git merge --no-ff -m "Remark information "development branch dev )
What if there are file conflicts when merging? After manually resolving conflicts, commit the code and then complete the merge.
4. Delete branch
After the branch is merged, the newly created branch (dev) can be deleted, using the following command:
git branch -d dev