Git old bird query manual

Author: hackett

WeChat official account: overtime ape

1. User name and mailbox configuration

Git config --global "git config --global"

2. Create a repository

Git init git init git init

3. Add files to the staging area

Git add readme.txt #readme.txt

4. Submit

Git commit -m "add a readme file."# -m

5. Fix last submission

Git --amend # In a nutshell, it can be understood to make an amendment to the last commit. < if the current last submission did not 'merge' >

6. Check the current warehouse status

Git status # current repository status

7. Look for differences in your files

Git diff readme.txt #readme.txt is the file you need to view

8. Review the commit log

Git log git log --graph --pretty=oneline --abbrev-commit# The third is to show COMMIT in short form

9. Version fallback

Git reset --hard HEAD^^ # git reset --hard HEAD~100 # git reset --hard HEAD~100 # git reset -- HARD 1094A # Backback to a version with a specific version number

10. View the version ID of the history

Git reflog # is an important command to use to recover from local errors

11. Look at the difference between a file workspace and a repository

Git diff HEAD -- readme.txt #readme.txt

12. Undo workspace changes (delete and restore by mistake)

Git checkout -- readme.txt # Undo the changes made to readme.txt in your workspace

13. Undo the change in the staging area

Git reset HEAD readme. TXT: git reset HEAD readme. TXT: git reset HEAD readme. TXT: git reset HEAD readme. TXT

14. Delete files

Git rm test.txt git rm test.txt

15. Relate remote repositories

Git remote add origin SSH link (name of repository) git remote rm origin

16. First push

 git push -u origin master 

17. Daily push

 git push origin master

18. Clone Warehouse

Git clone SSH: git clone SSH: git clone SSH

19. Create a branch

Git branch dev create a branch named dev

20. Switch branches

Git switch master: The contents of git switch master are unchanged

21. Create and switch to a branch

Git checkout -b dev git switch -c dev

22. Look at the branches

 git branch

23. Merge the specified branch into the current branch

Git merge dev git merge dev

24. Delete the branch

Git branch -d dev git branch -d feature-vulcan

25. View the merge of branches

 git log --graph --prett=oneline --abbrev-commit

26. Disable Fast Forward mode

 git merge --no-ff -m "merge with no-ff" dev

27. Save the current workspace

 git stash

28. Review preservation records

 git stash list

29. Record keeping operation

Git stash apply @{0} git stash apply @{0

30. Merge fixed bugs into branches

 git cherry-pick 4c805e2 

31. If push fails, merge first

Git pull git branch --set-upstream-to=origin/dev #pull No tracking information

32. Play tag

Git tag v1.0 git tag v0.9 f52c633 'git tag v0.8 0a1a47-m "test tag"

33. List all labels

 git tag 

34. View label details

Git show v0.9

35. Delete labels

Git tag - d v0.8

36. Push tags

Git push origin v1.0 git push origin

37. Delete pushed labels

Git push origin :refs/tags/v1.0

If you think the article is good, remember to “thumb up follow”.

Follow my WeChat official account [Work overtime apeYou can get more content