I wanted to reword my commit messages. I used git rebase --interactive
, and used reword
to alter commit messages. My expectations were that my tree will remain exactly the same, but with different commit messages. Instead, I ended up with 2 trees, one containing the original messages, one reworded ones.
I've edited the tree below to remove complexity, so maybe it is not a truest representation of where things went wrong, and why, but it is a clear representation of what I have right now. Notice that there are 4 messages the are the essentially the same, but are slightly reworded. I assure you that deltas are the same.
* 56bb877 (HEAD, bjyGuardProvider) BjyRuleAdapter: checkpoint! (same as 0e1f985)
* 6b765f1 Base: Added a new FedcoUser local module (same as 47e1cf9)
* bbfb764 Base: Added Zend Studio/Server deployment descriptor files (same as 6b7cc21)
* 8ee08b9 General: Added vendor modules (no configuration applied) (same as 4648e11)
| * 0e1f985 (origin/bjy, bjy) Checkpoint: BjyAuthorize works
| * 47e1cf9 Added a new FedcoUser local module
| * 6b7cc21 Added Zend Studio/Server deployment descriptor files
| * 4648e11 Added vendor modules (no configuration applied)
|/
* e539e7a Initial ZendSkeletonApplication
How do I fix this?
If it absolutely will help, I can put a link to the full tree somewhere, or provide any other info.
This is in fact a normal consequence of rebase, which does not modify existing commits, but instead adds new ones. You had this:
where commit
A
is theInitial ZendSkeletonApplication
one,B
isAdded vendor modules
, and so on.You then did a
git rebase -i
of commitsB
throughE
, whileHEAD
was telling git that the current branch isbjyGuardProvider
. Rebase copiedB
throughE
(hence the same trees) to new commits with new commit IDs, and made branch labelbjyGuardProvider
point to the end of the new chain:But it will not (and should not) move any other branch labels ... so
bjy
andorigin/bjy
remain attached to commitE
, on the old chain.If you move your own
bjy
label (manually) and force-push this to the git repository onorigin
, you may (depending on how permissiveorigin
is) be able to move all three labels to point to commitE'
. The old chain will no longer have any labels, and will be eligible for garbage collection, if those are indeed the only three labels that used to name those commits.If some third repository has a copy of the
origin
repository, however, they will still have the old labels and the old commits, and you will need to have them move their labels as well. As @poke noted in a comment, this is why rebasing published commits is discouraged. ("Should" and "should not" are ultimately value judgements—is the pain of getting all other repositories in sync, worth the benefit, whatever it is?—but the pain is as you have now seen.)