Common git command summary
- Common Git commands summary
- 1. Name and configure a global user E-mail
- 2. Initialize the warehouse
- 3. Add files to the Git repository
- 4. Add the file submitted to the Git repository
- 5. Check the current state of the repository
- 6. Compare modify the current file
- 7. Review the history submit records:
- 8. fallback version
- 9. Check the operation command history record
- 10.diff file
- 11. Discard changes to the workspace
- 12. discard the file staging area
- 13. Delete Files
- 14. Create SSH key
- 15. Collaboration with the remote warehouse
- 16.Git Branch Management
- 17. Review the history submitted
- Figure 18. View branches merge
- 19. Merge Branches
- 20. Save your work site
- 21. discard a branch had not been merged
- 22. View information about the remote repository
- 23. Push branch
- 24. Create a local branch
- 25. Specify local branch1 branch and remote origin / branch1 branch link
- 26. Create a label
- 27. Remove label:
- 28. Push the label to the remote database:
- 29. Custom settings Git
- 30. Set command aliases:
Common Git commands summary
1. Name and configure a global user E-mail
$ git config --global user.name “Your Name”
$ git config --global user.email “[email protected]”
2. Initialize the warehouse
git init
3. Add files to the Git repository
git add
Tip: it can be used repeatedly to add multiple files;
4. Add the file submitted to the Git repository
git commit -m "commit"
5. Check the current state of the repository
git status
6. Compare modify the current file
$ git diff
7. Review the history submit records:
git log --pretty=oneline
8. fallback version
$ git reset --hard HEAD^
9. Check the operation command history record
$ Go reflog
10.diff file
git diff HEAD –
11. Discard changes to the workspace
$ git checkout –
12. discard the file staging area
$ git reset HEAD
13. Delete Files
$ rm
14. Create SSH key
$ ssh-keygen -t rsa -C “[email protected]”
15. Collaboration with the remote warehouse
$ git remote add origin [email protected]:jieliuGG.git
- Delete local and remote database library association:
$ git Remote RM Origin - Pushed to the remote repository
$ git push -u origin master
Note: The first submission need to add a parameter -u, the future does not need - Clone a remote repository
$ git clone [email protected]: jieliuGG.git
16.Git Branch Management
- Creating a branch Branch1
$ git Branch Branch1 - Switch to branch1 branch:
$ Git Checkout branch1 - Create and switch to branch1 branch:
$ git Checkout -b branch1 - View branch:
$ git Branch - Branch to merge branch1 Master:
$ git Merge branch1 - Delete branch:
$ git Branch -d Branch1
17. Review the history submitted
$ git log
Figure 18. View branches merge
git log --graph
19. Merge Branches
$ git merge --no-ff -m “merge” branch1
20. Save your work site
$ git stash
21. discard a branch had not been merged
$ git branch -D
22. View information about the remote repository
$ git remote -v
23. Push branch
- Push master to the remote repository
$ git push origin master - Branch1 push to a remote repository
$ git push origin branch1
24. Create a local branch
$ git checkout -b branch1 origin/branch1
25. Specify local branch1 branch and remote origin / branch1 branch link
$ git branch --set-upstream branch1 origin/branch1
26. Create a label
$ Git tag
- View all tags:
$ git Tag - Look at the label information:
$ git Show - Create a label with instructions, with the specified tag name -a, -m specify caption, the above mentioned id 123456 to the commit:
$ git Tag v1.0 -a -m "V1.0 Released" 123456
27. Remove label:
$ Git tag -d
delete the label remote repository:
- First remove the local tag: $ git tag -d V1.0
- Push again be deleted: $ git push origin: refs / tags / V1.0
28. Push the label to the remote database:
$ Git push origin
to push all the tags to the remote repository:
$ git push origin the --tags
29. Custom settings Git
Git display color, the command output will look clearer eye-catching:
$ git config to true --global color.ui
30. Set command aliases:
$ git config --global alias.st status