Tag: git
I used tortoisegit for development in windows. I recently encountered a Linux project, so I started to use the GIT command and found that it was really nice to use it, the following are some frequently used commands that I need to summarize from my work.
Create a repository git init
Clone git clone URL
Update code git pull
Code submission
4.1 git add path/file name eg: git add APP/controller/cart_controller.rb
4.2 git commit-M "comment" eg: git commit-M "Modify bug001"
4.3 git push
5. Check the status
Check which code you have modified
Git status
6. view log
Git log
7. view the branch Graph
Git log -- Graph
8. Sometimes you may encounter a situation where the modification is complete and needs to be restored and used.
Git checkout -- path/file name
9. Check the submitted commit ID. This ID is still very useful. For example, if you want to view the specified log and restore it to the specified version, you need this ID.
Git reflog
10. view the specified log git log commit ID
Restore to the specified version of git reset -- hard commit ID
11. Sometimes you execute git add to the temporary storage area, but want to restore it, you need to use the following command
Git reset Head XXX. Rb
Now it is restored to the work zone. If you want to continue restoring it, use git checkout -- file name
12. Create a local branch and switch to the new branch.
Git checkout-B si_dev (my new Branch)
You can also take two steps.
Create git branch si_dev
Git checkout si_dev Switch
After si_dev modifies the code
Git add xxx
Git commit-M "XXXXX"
Switch to the original master branch, and then merge
Git checkout develop
Git merge si_dev
Git push
13. Delete used branches
Git branch-D si_dev
14. View submitted specified files
Git show commit ID file name
15. When a code conflict is submitted, either stash or stash is prompted .... (I showed up at push)
First, run git stash to restore the code.
Then git pull updates the code.
Then, bring the restored code pop to the master.
Git pop
16. Create a remote Branch
This article from the "monkey riding Tree" blog, please be sure to keep this source http://qihoushangshu.blog.51cto.com/7872138/1570557
Common git commands