I did a revert to a commit (pushed to remote of course).
Then I saw after 2 new commits that someone modified the code that my commit reverted without an intermediate revert of my revert.
How is this done?
Asked
Active
Viewed 146 times
0

Jim
- 18,826
- 34
- 135
- 254
1 Answers
0
Simple enough. Let's say you changed README.txt
:
-We don't support fribble mode.
+We do support fribble mode.
You commit that, then realize it's wrong and revert it. (The README now says we don't support fribble mode, again.)
Bob, meanwhile, is editing README.txt
. He gets your wrong version in his editor. It says that we do support fribble mode.
He updates his repository and work-tree, keeping the wrong version in his editor.
He writes his wrong version to the work-tree and adds the file.
Meanwhile, he also makes the change he intended to make (whether that's to README.txt
or to some other files). He writes those changes and git add
s them.
Now he commits, and he has changed README.txt
to include the part you reverted. He pushes, and now Bob has undone your revert.

torek
- 448,244
- 59
- 642
- 775
-
So there would be no conflict? – Jim Feb 14 '17 at 21:19
-
Not if you're dumb about it, as Bob was. Some editors are smart and will notice that the file changed underneath, and warn you, but if you tell them to, they'll just overwrite anyway. Find out *who* undid your revert, and talk to him (it's usually a "him"...). Also, it wasn't necessarily an editor session, although that's where I've seen most people do it. No matter what, though, it was Bob (or whoever made the commit) that did it. – torek Feb 14 '17 at 21:22
-
So doing a pull rebase is irrelevant in this case? – Jim Feb 14 '17 at 22:30
-
You didn't mention any pulls or rebases. But for what it's worth: `git pull` just means (abbreviated and minus a lot of fiddly details) `git fetch && git merge`. `git rebase` means "copy some commits and move a branch name". `git pull --rebase` means `git fetch && git rebase` instead of `git fetch && git merge`. None of these individual operations will undo a commit in and of itself, but `git rebase` can be instructed to *omit* commits on purpose. It takes a lot more details about who was doing what to say more. – torek Feb 14 '17 at 22:39
-
The other person would be ahead of remote i.e. when git adding the changes I reverted. Then he can't push without pulling first. git won't let that right? So a pull was needed. So the pull won't show any conflicts? I actually removed a file with the revert. Even in that case he modified the old local file and commiting that won't conflict with the revert that removed the file? – Jim Feb 14 '17 at 23:19
-
Once again, `git pull` is just `git fetch` followed by another Git command. Everything depends on (1) what you fetch and (2) what second command you use. You're now noting that your revert deleted a file. We now need to know which commands Bob ran, and when, and what he did when he encountered any issues such as files being removed from his work-tree as a result of a merge or rebase. When you're looking for speculative scenarios ("what did Bob do to achieve this") it helps to give all the background information you have, but ultimately, we must ask Bob. – torek Feb 15 '17 at 01:01