Most important flows in Git

Save data in temporary memory and pull it whenever needed

1| Save data in temporary memory

git stash

2| Now pull changes from the master

git pull origin master --rebase

3| Finally pull back the value stored in temporary memory

git stash pop

Squash/Squeeze multiple commits as one

1| Check for the number of commits made in a single branch

git log

2| Mention the total number of commits to squash; say, 3

git rebase -i HEAD~3

3| Pick the top commit and squash following commits. How to do? Replace the text ‘pick’ with ‘s’ on following commit lines except the first one, and save “:wq”

4| Now, comment out all the commit names except the one you need to pick, and save “:wq”

5| Rebase the changes from master

git pull origin master --rebase

6| Fix the conflicts
7| Check for status

git status

8| If everything is perfect, then continue

git rebase --continue

9| And finally force push the commit

git push -f origin master

 

Leave a comment