ssvs

Git

Nov 27th, 2021 (edited)
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.47 KB | None | 0 0
  1. git log                                         => show all commits
  2. git branch -a                                   => show all branches
  3. git merge --squash branch-name                  => upload your changes to another branch
  4.  
  5.     <====================================================================>
  6.  
  7. git checkout commit-id                          => switch to another commit (detached head)
  8.                                                 => commit changes and create a branch to save commit
  9.                                                 => merge a new branch to master branch then delete it
  10.  
  11.     <====================================================================>
  12.  
  13. git checkout .                                  => delete all changes in unstage
  14. git restore .
  15.  
  16. git clean -df                                   => delete all untracked files in unstage
  17.  
  18. git checkout file.txt                           => delete all changes in unstage in specific file
  19.  
  20. git reset .                                     => switch from stage to unstage
  21. git restore --stage .
  22.  
  23. git reset --soft HEAD~1                         => delete a last commit and switch back to stage
  24. git reset HEAD~1                                => delete a last commit and switch back to unstage
  25. git reset --hard HEAD~1                         => delete a last commit and all changes
  26.  
  27. git branch -D branch-name                       => delete a branch
  28.  
  29. .gitignore                                      => *.test:      ignore all .test files
  30.                                                 => !log.test:   exclude log.test file
  31.  
  32.     <====================================================================>
  33.  
  34. git stash push -m "message"                     => save all changes and switch back to last commit
  35. git stash apply                                 => go back to your changes
  36. git stash list                                  => show all stash versions
  37. git stash apply stash-version                   =>  go back to your specific stash changes
  38. git stash pop stash-version                     => apply stash version then delete it from the list
  39. git stash drop stash-version                    => delete specific stash-version
  40.  
  41.     <====================================================================>
  42.  
  43. git reflog                                      => show all changes (commits, added, deleted)
  44. git reset --hard change-id                      => restore a deleted commit
  45. git checkout change-id                          => another way to restore (detached head)
  46.  
  47.     <====================================================================>
  48.  
  49. git tag 1.0 commit-id                           => save a tag
  50. git show 1.0                                    => show commit-id
  51. git tag -d 1.0                                  => delete a tag
  52. git tag -a 2.0 -m "message"                     => tag a current commit
  53.  
  54.     <====================================================================>
  55.  
  56. git pull                                        => up to date all changes
  57. git checkout feat/cart                          => without remote/origin to create a branch and bind it with remote one
  58.                                                 => this step if I wanna go to his branch and make changes
Add Comment
Please, Sign In to add comment