I'm trying to squash a few commits in a git repository.
> git rebase -i HEAD~3
Successfully rebased and updated refs/heads/staging.
A file opens titled git-rebase-todo
:
pick a2f3467 Require statement incorrect pick c41212e Require file in environment pick 2743221 This should work # Rebase c5f42f3..2743221 onto c5f42f3 # ..........
I tried changing the bottom two commits to squash
from pick
. I save the file, and I get the following error:
Unable to save ~/Documents/code/myapp/.git/rebase-emrge/git-rebase-todo
The golden rule of git rebase is to never use it on public branches. The rebase moves all of the commits in main onto the tip of feature . The problem is that this only happened in your repository. All of the other developers are still working with the original main .
Rebasing can be dangerous! Rewriting history of shared branches is prone to team work breakage. This can be mitigated by doing the rebase/squash on a copy of the feature branch, but rebase carries the implication that competence and carefulness must be employed.
squash does not touch your source branch ( tmp here) and creates a single commit where you want. rebase allows you to go on on the same source branch (still tmp ) with: a new base. a cleaner history.
When you perform a git rebase operation, you're typically moving commits around. Because of this, you might get into a situation where a merge conflict is introduced. That means that two of your commits modified the same line in the same file, and Git doesn't know which change to apply.
The problem is that when sublimetext2 is started, it doesn't block and immediately returns. Git then thinks that you're done editing the file and performs the rebase. That's why you see the
Successfully rebased and updated refs/heads/staging
message, before you even edited the file. Use the subl
command instead, which is designed for such use. The github help tells you do configure it with
git config --global core.editor "subl -n -w"
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