Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. // force push
  2. git push --force
  3.  
  4. //Identify merged branches
  5. git branch --merged
  6. git branch --no-merged
  7.  
  8. //Delete local Branches
  9. git branch -d branchname
  10. //delete remote branch
  11. git push origin :namebranch
  12.  
  13. // reset to commit ()
  14. git reset --hard shacode
  15.  
  16. //Create tag
  17. git tag -am "Description" nametag shacode
  18. //list tags
  19. git tag -l
  20. git tag -n v*
  21. git tag -l -n
  22. // go to this tag
  23. git checkout tagname
  24. //To push a single tag
  25. git push origin <tag_name>
  26. //Push all tags
  27. git push --tags
  28. // Fetch tags
  29. git fetch --tags
  30.  
  31. // go to interactive mode
  32. git add -i
  33.  
  34.  
  35. // Do cherry pick
  36. git cherry-pick
  37. // solver merged pick
  38. git add .
  39. git cherry-pick --continue
  40.  
  41. //
  42. git checkout -- finemaestaged
  43.  
  44. //patches -> past changes without commit
  45. git diff onebeforeinitialcommitsha..lastcommitsha > filename.diff
  46. //apply patch
  47. git apply filename.diff
  48.  
  49. //format patch
  50. git format-patch onebeforeinitialcommitsha..lastcommitsha > directory
  51. //apply format patch
  52. git am filename.patch
  53. git am <directory>/filename.patch
  54.  
  55. // REBASE: Manage and incorporate changes between new branches
  56. // Useful to integrate recent commits without merging
  57. // Put branch at the end of other branch
  58.  
  59. // Rebase current branch at the end of master
  60. git rebase master
  61. // Rebase new_feature branch at the end of master
  62. git rebase master new_feature
  63. // usefu for visualizing branches
  64. git log --graph --all --decorate --oneline
  65. // Return commit where topic branch diverges
  66. git merge-base master new_feature
  67.  
  68. /// Resolver rebase confict
  69. // solve the merge and execute
  70. git add filename
  71. git rebase --continue
  72. // if you want to skip this patch
  73. git rebase --skip
  74. // if you want to abort
  75. git rebase --abort
  76. ///rebase onto other branches
  77. // syntax => git rebase --onto newbase upstream branch
  78. // example: rebase new feature branch of ecommerce branche onto master
  79. git rebase --onto master ecommerce new_feature
  80. // Undo rebase: can only for simple rebases(they are destructives)
  81. git reset --hard ORIG_HEAD
  82. // interactive Rebase: Rebase new_feature to master branch
  83. git rebase -i master new_feature
  84. /// Rebase last 3 commits onto the same branch but with the opportunity to modify them
  85. git rebase -i HEAD~3 //also used for clean small commit about the same thing
  86. // If appear the interactive file, first select pick, second squash, thirt fixup
  87.  
  88. // pull rebase: Fetch and rebase, only use it for local branches
  89. git pull --rebase
  90. git pull -r
  91. git pull --rebase=preserve // preserve locally commit merge created
  92. git pull --rebase=interactive
  93.  
  94. ///Logs
  95. //List commits as patches
  96. git log -p
  97. git log --patch
  98. //List edits to lines 100-150 in filename.txt
  99. git log -L 100,150:filename.txt
  100. // after git log -> find a word use '/word' and if you want to see next occurrence press 'n', previus ocurrence 'N'
  101.  
  102. /// Blame
  103. // Annotate file with commit details
  104. git blame filename.txt
  105. // Ignore whitespaces
  106. git blame -w filename.txt
  107. // Annotate lines
  108. git blame -L 100,150:filename.txt
  109. git blame -L 100,+5:filename.txt
  110. // Annotate file at revision d9dba0
  111. git blame d9dba0 filename.txt
  112. git blame -- d9dba0 filename.txt
  113. // Add global alias for 'praise'
  114. git config --blobal alias.praise blame
  115. // Similar to blame, different output
  116. git annotate filename.txt
  117.  
  118. // Bisect: Find the commit that introduced a bug or regression
  119. git bisect start
  120. git bisect bad <sha> // is not specify sha, will be last commit
  121. git bisect good <sha>
  122. git bisect reset
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement