当前位置:网站首页>Git old bird search manual

Git old bird search manual

2020-11-09 19:11:00 CodingEmbedded

Git Old bird search manual

 Insert picture description here

author :hackett

WeChat official account : Overtime ape

1. user name , Mailbox configuration

 git config --global user.name " user name "
 git config --global user.email " mailbox "

2. Create repository

 git init # The current directory creates a warehouse 

3. Add files to staging area

 git add readme.txt #readme.txt For the files that need to be added 

4. Submit

 git commit -m "add a readme file."# -m  The following is the submission record 

5. Fixed last submission

 git --amend # To put it simply , It's understandable to make a correction for the last submission .< The premise is that the current last submission did not `merge`>

6. View the current warehouse status

 git status # Current warehouse status 

7. Look at the differences in the files

 git diff readme.txt #readme.txt For files that need to be viewed 

8. View the commit log record

 git log 
 git log --pretty=oneline # Show a log line 
 git log --graph --pretty=oneline --abbrev-commit# The first parameter is graph view   The second is to display a line of records   The third is a brief form showing commit

9. Version rollback

 git reset --hard HEAD^ # Back to previous version  
 git reset --hard HEAD^^ # Go back to the previous version  
 git reset --hard HEAD~100 # Back to front 100 A version  
 git reset --hard 1094a # Go back to the version with a specific version number  

10. View version number of history id

 git reflog # An important command to recover local error operations 

11. See the difference between a file workspace and a version Library

 git diff HEAD -- readme.txt #readme.txt The difference between 

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

 git checkout -- readme.txt # Undo workspace readme.txt Modification of 

13. Undo changes to staging area (add After revocation )

 git reset HEAD readme.txt ## Undo the staging area readme.txt Modification of 

14. Delete file

 git rm test.txt # Delete file test.txt

15. Associated remote warehouse

 git remote add origin SSH link  # Change to the link you want to associate with ( Warehouse, )
 git remote rm origin # Delete Association 

16. First push

 git push -u origin master 

17. Daily push

 git push origin master

18. Cloning of warehouse

 git clone SSH link  # Change to the link you want to clone ( Warehouse, )

19. Create a branch

 git branch dev # Create a file called dev The branch of 

20. Switch branches

 git checkout master # Recovery of changed workspace  
 git switch master # The content of the workspace does not change 

21. Create and switch to branches

 git checkout -b dev
 git switch -c dev # New version command 

22. View branches

 git branch

23. Merge the specified branch to the current branch

 git merge dev # Merge dev Branch  

24. Delete the branch

 git branch -d dev 
 git branch -D feature-vulcan # Mandatory deletion 

25. See the merging of branches

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

26. Ban Fast forward Pattern

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

27. Save the current workspace

 git stash

28. View saved records

 git stash list

29. Save record operation

 git stash apply # recovery  
 git stash pop # Recover and delete  
 git stash drop # Delete record  
 git stash apply stash@{0} # Application saved records 

30. Merge and repair bug To the branch

 git cherry-pick 4c805e2 

31. After the push failed , Merge first

 git pull 
 git branch --set-upstream-to=origin/dev dev  #pull Failure tips no tracking information When using  

32. tagging

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

33. List all the tags

 git tag 

34. Check the label details

 git show v0.9 

35. Remove the label

 git tag -d v0.8 

36. Push tag

 git push origin v1.0 
 git push origin --tags  # Push all tags 

37. Delete push tags

 git tag -d v1.0 
 git push origin :refs/tags/v1.0 

If you think the article is good , Remember " Like and focus on "

Pay attention to my WeChat official account 【 Overtime ape 】 You can get more

版权声明
本文为[CodingEmbedded]所创,转载请带上原文链接,感谢