Here is only a list of commands, just to work when suddenly remember, look at it to remember how to use, the principle is not added.
- View the current branch in use (an asterisk in the result list indicates the current branch in use)
git branch
Copy the code
- Viewing remote branches
git branch -r
Copy the code
- View all branches
git branch -a
Copy the code
- Switch branch
Git Checkout branch nameCopy the code
- Switching remote branches
Create a new branch locally, call it “local branch name”, and switch to that branch.
Git checkout -b specifies the origin/ remote branch nameCopy the code
- Deleting a Local Branch
For example, the warehouse has local branches 1 and 2. Now the warehouse is on branch 1 and you want to delete branch 1 as follows.
Git branch -d 1 git branch -d 1 git branch -d 1 git branch -d 1Copy the code
- Delete remote branches (with caution)
For example, if there is a remote branch origin/ branch 1, the local command line deletes it as follows:
git push origin --delete dev20181018
Copy the code
- Fetch code in public bin:
Pull the origin/ branch 1 code node from the remote repository onto the local branch 1.
Git fetch origin branch 1: branch 1Copy the code
Git fetch is to pull the latest content from the remote host to the local, which the user checks and decides whether to merge into the working native branch.
Git pull is used to pull down the latest contents of the remote host and merge them, that is, git pull = git fetch + git merge. Conflicts may occur and need to be resolved manually.