git log
View project history information
git status
The git status command is used to display the status of the working directory and staging area. Use this command to see which changes are temporarily saved, which are not, and which files are not tracked by Git. Git status does not display information that has been committed to the project history.
git stash
Application scenarios
- Some of the code is redundant and you want to keep it for later review, but you don’t want to commit it to a remote branch
- When making multiple branch development, such as your development on A branch, but suddenly found that there is A bug in B branch needs to be fixed, tend to put on A branch before developing the function of the half local commit, switch to the branch B bug fixes, and then switch back to A branch continue to develop, so often will have A lot of unnecessary record log. Now available
git stash
Push any code you don’t commit locally (and to the server) onto Git’s stack, go to branch B to fix the code, and then switch back to branch Agit stash apply
Applying half of what you did before;
Git pull (B) Git stash apply (A)Copy the code
The PS: git Stash list command can be used to place changes in the current branch into the cache and automatically create a list of caches for easy management.
git stash list
Copy the code
git stash save
git stash
git stash save "Is added to the console. The log"
Copy the code
git stash list
Copy the code
git stash apply
git stash pop
git stash apply stash@{x}
git stash apply
git stash pop
- If you really don’t want to make local changes, you can clear all stash stacks using the following command
git stash
git stash clear
Copy the code
You can also use the Git Stash drop to remove the specified stash stack
git stash drop stash@{1}
Copy the code
View the reference diff of the specified stash
git stash show
Copy the code
After the operation
git stash show -p
git stash show --patch
Git rebase conflict
-
Step 1. Use git status to check for file conflicts and resolve them one by one
-
Step 2. Open the conflict file and find the location of the conflict. Such as modify the user information after sending events < < < < < < < HEAD b789 = = = = = = = b45678910 > > > > > > > 6853 e5ff961e684d3a6c02d4d06183b5ff330dcc conflict tag < < < < < < < (7) and = = = = = = = between local modification, is the content of the = = = = = = = > and > > > > > > is the content between the change of others.
-
The easiest way to do this is to delete the conflicting flags and check to see if any of them are identical.
-
Git add. Git commit -m “fix conflict”
-
step 5. git rebase –continue
-
If the conflict persists, repeat steps 2 to 5
-
Step 7. Complete
Branch management
git branch test // Create a branch (test)
git branch -d test // Delete branch (test)
git branch -D test // Force drop branch (test)
git checkout test // Switch to the test branch (test)
git branch // View the local branch
git branch -r // View the server remote branch
git branch -a // View local and remote branches
git branch -b develop
Copy the code
The new branch must be submitted to the remote server to pull the code.
git push origin test // Submit to remote server (test)
Copy the code
git merge git cherry-pick
Git merge merge git merge merge git merge merge git merge merge git merge Choose to merge one or more commits. For example, to merge A commit from branch A to branch B, A – >B, do as follows
- Step 1: Under branch A, git log to obtain A commit-ID
- Switch to branch B and git checkout B. Make sure there are no uncommitted changes or stash changes in branch A before executing this command.
- Git cherry-pick {commit-id}
- For example, IF I modify A file in branch A, I need to commit it to branch A and branch B at the same time. Perform the following operations in branch A
Git add. Git commit -m "{commit comment}" git pull - -- rebase origin A git push origin A git log git status git checkout BCopy the code
You have switched to branch B. After switching to branch B, you must first go to branch B to obtain the latest content
Git pull -- rebase origin B git cherry-pick {commit-id} git pull -- rebase origin B git push origin BCopy the code
Git tag
It is recommended that you tag only the main branch, and that you tag only after the release of the version
Gitlab Flow upstream priority
www.ruanyifeng.com/blog/2015/1… www.cnblogs.com/cnblogsfans…
Small tips
git commit --amend
– “Modify the description of commit”- perform
git pull
“Commit”, “commit”, “commit”error: Cannot pull with rebase: You have unstated changes.
“