0

We use a single branch for all the users. Every time a user tries to push, he needs to pull others changes first. This results in a git automerge which works fine in most of the scenarios.

Yesterday, one of our users did the above and it resulted in a conflict, which failed the automerge. Now, the person resolved the conflicts and instead of committing all the files as part of this merge, committed and pushed only the conflicted file (after resolving them).

This has resulted in a situation, where all the files which he didn't commit are now being shown as old in the remote repo.

The changes are still there on his machine and we can also see them in git if we go to the file history but are not getting pulled.

Any way out of this?

BTW, we don't use --rebase or --ff-only options.

Nikhil Gupta
  • 1,708
  • 1
  • 23
  • 38
  • try resetting the branch to earlier commit. – eatSleepCode Mar 11 '14 at 06:40
  • or cherry pick all commits which are overwritten and push them again – eatSleepCode Mar 11 '14 at 06:42
  • The changes are already on remote. resetting would change them in my local, how would I push? Cherry-pick is not an option, the changes lost are many and across multiple files. – Nikhil Gupta Mar 11 '14 at 06:44
  • You need to cherry pick each commit and push again to remote so that overwritten changes by this commit will be there on remote. – eatSleepCode Mar 11 '14 at 06:45
  • Is there no other way? The changes might run into a couple of weeks. The dude had just come back from vacation. BTW, why should this happen ? Sorry, but I'm a noob on git. – Nikhil Gupta Mar 11 '14 at 06:51
  • Can I ask this guy to reset -hard on his machine and then make his changes again? How would it affect the other people who have already pulled after this change? – Nikhil Gupta Mar 11 '14 at 06:57
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/49450/discussion-between-nikhil-gupta-and-eatsleepcode) – Nikhil Gupta Mar 11 '14 at 06:59
  • BTW, how would I be able to push after a reset --hard. Wouldn't git ask me to pull again? – Nikhil Gupta Mar 11 '14 at 07:26

1 Answers1

0

This is how I resolved this -

  • There were 5-6 commits on top of the erroneous commit.
  • We reverted those commits, along with the erroneous commit.
  • Committed and pushed the correct files again.
  • Replayed the commits reverted again.

I've asked another question here to understand why it should be this way.

Special Thanks to @eatSleepCode for this help in suggesting the solution.

Community
  • 1
  • 1
Nikhil Gupta
  • 1,708
  • 1
  • 23
  • 38