Last Friday, I used git reset -- HARD <commit-id> and lost my commit (poor). So I decided to re-learn git.
This article is not about git-based things, but about things you don't know or just use once or twice.
Restore submission from reset -- HARD
Just use the git reflog command.
(Provided by Gittenberg)
Diff
If you want to see the differences between the two branches, you only need to do this: git diff branch1.. branch2.
Use regular expressions to match submitted information and display
Using the git show:/fixes command, you can find the most recent commit that contains the input string (fixes in this example) in the submit information.
Restrict default behavior of git push
If you run git push, the default behavior is to submit all the branches to the remote code library. This may cause many problems. If you do not want to do this, you can: git config -- global push. default tracking.
Update: Git 2.0 removed this default behavior http://blog.nicoschuele.com/posts/git-2-0-changes-push-default-to-simple
Switch to a branch rebase and merge to master
You can do this: git rebase HEAD feature & git rebase HEAD @ {-2}
Git save working status
If your work is not completed yet, but you need to find it urgently, you can use git stash to save the changes and submit your urgent task, then use git stash pop to restore to the state you saved.
Alias
Are you still tired of entering checkout again and again? Now let's try: git config -- global alias. co checkout. You can use the git co master command to switch to the master.
Rename a local branch
Use: git branch-m old-name new-name you can easily rename a local branch.
Search for author name
You can use git log -- author = Matheus to search for a submission record of a specified author.
Add parameters to git status
Most people only use git status. However, you can pass in parameters to change the state display mode.
Using git status-sb, you can get output similar to the following:
## master M Gemfile M Gemfile.lock M app/controllers/home_controller.rb M app/views/home/index.html.erb
Install Git on Ubuntu Server
Create a Git repository on the server (Ubuntu)
Git simple tutorial in Linux (taking Android as an example)
Git authoritative guide PDF
Git details: click here
Git: click here
This article permanently updates the link address: