I have just started using git. Rebase is great stuff. I should have used it in a specific earlier case.
is there a perfectly acceptable way to rebase old commits for the sake of clear commits?
Keep in mind that you need at least one commit to be picked before the one you want to squash in order to be able to do so, which means you can't choose to squash the first one. Every commit you squash will be squashed into the previous one that was executed.
Running rebase in interactive mode and executing subcommands like squash or drop will remove commits from your branche's immediate log.
Interactive Rebase also allows you to reorder commits. Simply drag and drop a commit between two existing commits to reorder history.
For each change you make, you'll need to perform a new commit, and you can do that by entering the git commit --amend command. When you're finished making all your changes, you can run git rebase --continue . As before, Git is showing the commit message for you to edit.
You should positively only do this for commits that have not been pushed upstream. That said, I find it easiest to use git rebase -i <commit>
where <commit>
is the id of a commit that is at least as old as the newest one you do not want to mess with. When your editor pops up, it will contain instructions about how to squash and/or delete commits.
In general, if you've shared a commit with someone else, don't rebase it.
If you haven't shared a commit with anyone else, you can do whatever you want to it.
See the "RECOVERING FROM UPSTREAM REBASE" section of the git-rebase
manpage for more info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With