Why we need Git consultants
Because this is how I reverted a range of commits and squashed them.
I want to squash them because I want to revert those commits in an
atomic way, so that next time I can easily revert the revert.
(To protect the witness, all the SHA1s are fakes)
I don't see there's any
Well, I don't care, just continue rebasing.
so do it again... Change the second "pick" to "s" to squash it as well.
And check with
and also
nothing because that's the point we want to revert to.
You're screwed if you don't understand how Git works enough.
Well, I am not sure if I understand enough, so I am leaving this
note to myself, and see if anyone can correct me.
I want to squash them because I want to revert those commits in an
atomic way, so that next time I can easily revert the revert.
(To protect the witness, all the SHA1s are fakes)
git revert f2b750aa00f3152e035c21d0fea4adb97fa297c5..HEAD
And keep saying yes for the commit messages.git revert -m 0 51d626e4e9714d17611fc8118665aa680744f65c
A merge commit cannot be reverted in a normal way, so we need another step.git rebase -i
Change all the "pick" to "s" for squashing for all commits except the first one.git rebase --continue
No idea what's going on, what empty commit? I don't understand.I don't see there's any
--allow-empty
option which I can use.Well, I don't care, just continue rebasing.
git rebase -i
Well, it's weird that the there's still one commit left without squashed,so do it again... Change the second "pick" to "s" to squash it as well.
And check with
git status
and git show
,and also
git diff POINT_WE_WANT..HEAD
should shownothing because that's the point we want to revert to.
You're screwed if you don't understand how Git works enough.
Well, I am not sure if I understand enough, so I am leaving this
note to myself, and see if anyone can correct me.
git --version
git version 1.7.12.3
2 retries:
My Approach 1:
git reset --hard && git clean -fdx #Cleanup everything before doing revert
git diff --full-index HEAD..f2b7 | git apply # Apply the reverse diff
git add . # Add new files
git commit -a -m "Revert to f2b7" # -a handles deletion
git diff f2b7 # Clean!
My Approach 2:
# Assume we are in "master" branch and it's identical to "origin/master" branch
git reset --hard && git clean -fdx # Cleanup everything before doing revert
git reset --hard f2b7 # Everyone knows hard reset
git reset --soft origin/master # Soft reset is the trick
git commit -m "revert to f2b7"
git diff f2b7 # Clean!
nice!!
i should have thought about this before.
i guess i was stuck on `git revert`,
the only advantage of using `git revert` might be the commit message
which it would generate for you. i don't feel that's very
important though
Post a Comment
Note: Only a member of this blog may post a comment.