Thursday, August 25, 2016

git 101: rebase from master, squash, etc

I prefer to use SourceTree for git access, and admittedly have generally been leaning "just enough to get by".

I was generally "pulling" from master periodically when working on a story branch, but was introduced to "git rebase master" which does a better job of it - your commits are more your new work, not just a record of the the commits as you kept up with master.

This link has some more about the squash option (like if you do "git rebase -i master"- this will fire up whatever editor you have on git, with lines showing you the commits separately, as "pick" - you have the option of changing all but the first "pick" to "squash" or "fixup" which essentially is saying "treat all these commits changes as one big commit). Once you close the editor, the editor will open again but with a place for the actual commit message you want to include.

I'm not sure what the benefit of squash-ing i, except keeping things a bit neater downstream, or if you have to rollback.

UPDATE: once you do this you have to do a "git push --force-with-lease" since you are rewriting history