Guest User

Untitled

a guest
Jan 19th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. # SQUASH
  2.  
  3. Whenever you want to squash last commits in a single commit:-
  4.  
  5. first check your log
  6.  
  7. `git log`
  8.  
  9. ### CASE 1: your head is at the commit in which you want others to be squashed
  10.  
  11. count number of commits to be squashed. Let the number of commits be x
  12.  
  13. open rebase window using HEAD
  14.  
  15. `git rebase -i HEAD~x`
  16.  
  17. ### CASE 2: Your head is not at the commit which you want to squash
  18.  
  19. Note the SHA commit value of the oldest commit from where you have to start squashing
  20.  
  21. open rebase window using SHA value
  22.  
  23. `git rebase -i <first 7 alphnumerics of SHA>`
  24.  
  25. Follow the instruction and make the changes accordingly
  26.  
  27. ## TO SAVE
  28.  
  29. press esc key
  30.  
  31. type :x!
  32.  
  33. press return key
  34.  
  35. write your final commit message
  36.  
  37. press esc again
  38.  
  39. type :wq! or :x!
  40.  
  41. press return key
  42.  
  43. ## PUSH (if all these extra commits were pushed in GitHub repo also)
  44.  
  45. you have to push changes forcefully
  46.  
  47. `git push -f origin master`
  48.  
  49. replace 'origin' with your remote name and 'master' with your branch name.
  50.  
  51. > Squash it up ;)
Add Comment
Please, Sign In to add comment