The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Practical Git: Clean up commits with git rebase

Practical Git: Clean up commits with git rebase

5:42
Sometimes its nice to clean up commits before merging them into your main code repo; in this lesson, we go over using `git rebase` to `squash` commits together and then rename the condensed commit message. We also talk about potential issues with rebasing and where to be careful.
Watch this lesson now
Avatar
egghead.io

Sometimes its nice to clean up commits before merging them into your main code repo; in this lesson, we go over using git rebase to squash commits together and then rename the condensed commit message. We also talk about potential issues with rebasing and where to be careful.

Avatar
CG

You could have pointed out that when doing interactive rebasing the commits are actually shown in reverse order (aka chronological order) and not in the "normal" order like for example with git log where the last commit is first.
It's more obvious then why you do need to leave the first commit in the list with the pick option because it's the oldest commit in which you "meld" the rest of the commits.
Also you didn't present the commit --amend option. Knowing about that helped me understand easier what a squash is.
Great course though. Really like the format. Cheers.

In reply to egghead.io
Avatar
omar

Does git push --force-with-lease will do a better job?

Avatar
Trevor

@omar, thanks for the comment. I didn't include it --force-with-lease in this course for two reasons 1) it is only available in later versions of git that not everyone has and 2) in my opinion, you should never use --force except on your own branch that only you are working on, so --force and ---force-with-lease have the same result (since there is nobody else's work that you could possibly override). So, in my mind, ---force-with-lease should never be needed because you shouldn't force a push if it is going to a place where someone else is contributing as well - where history could be damaged. But that's my 2 cents :)

In reply to omar
Avatar
Trevor

@CG, thank you for your feedback

In reply to CG
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?