git fetch: Synchronize remote code to local library
git merge branch-a: Merge the branch branch-a into the current branch, pay attention not to merge the current branch into the branch-a branch
git pull: Pull the code on the remote branch to the local and automatically merge it into the current branch, git pull = git fetch + git merge
Note: If the connection between the local branch and the remote branch is established, the remote branch name may not be written after the pull, otherwise the command will be invalid. At this time, either manually enter the remote branch name after the pull, or enter the command git branch --set- upstream-to=origin/current-branch establishes a connection between the local and remote branches, and the same is true for git push.
git branch: view all local branches
git branch -r: view all remote branches
git branch -a: view all local and remote branches
git branch new-branch: create a new local branch
git checkout new-branch: switch to the new branch
git checkout -b new-branch: first create a new local branch, then switch to this branch, git checkout -b new-
branch = git branch new-branch + git checkout new-branch
git add fileName: Add a single file to the temporary storage area, include it in version control, and tell git to start processing this file
track
git add . or git add *: Add all files to the temporary storage area and include them in version control
git commit file1 file2 -m "content" : Submit the two files in the temporary storage area to the local repository, and the content is this time
The submitted content can be input freely, note that file1 and file2 must be added first
add to staging area
git commit -m "content" : Submit all files in the temporary storage area to the local repository
git push origin origin-branch: Push all files submitted to the local repository to the remote branch
git clone url: copy the remote code library to the local computer, url indicates the address of the remote warehouse
git status: View the status of the workspace and temporary storage area. Generally, there are three types. One is that the newly created files are not tracked, that is, they are not
There is add to the temporary storage area; one is that the file has been added to the temporary storage area but not committed (commit); the other is that the file has been submitted but not pushed (push) to the remote warehouse
git branch -d branchName: delete local branch
git branch -d -r origin/branchName: delete the remote branch stored locally, note that the actual remote branch is not deleted
, after git pull, those deleted branches will be reproduced locally
git push origin -d branch1 branch2: delete the remote branch in the true sense
git fetch -p or git remote prune origin: clean up remote branches that no longer exist in the local warehouse, it will delete the remote branch
Branches that no longer exist in the project warehouse but still exist in the local warehouse, and
Keep the local warehouse in sync with the remote warehouse
git log: View the historical submission records, after viewing, you need to return to the main page and press q directly
reset: Clear the content of the work interface, similar to the effect of clear
git branch -vv: View the correspondence between the local branch and the remote branch. The blue branch name indicates that there is a relationship between the local branch and the remote branch
Steps to create a remote branch:
1. git checkout -b branch_name //Create a new branch locally and switch to it
2. git push origin branch_name //Push the newly created local branch to the remote warehouse
3. git branch --set-upstream-to=origin/branch_name //Connect the newly created local branch with the branch pushed to the remote
Note: The second and third steps can also be combined into one step: git push -u origin branch_name or git push --set-upstream origin branch_name