Cannot resolve conflict on Git (remote is 1 commit ahead)

41 views Asked by At

A project that I'm working on has around 200 submodules. I made some modifications in my local repo, around changes to 150 submodules without commit & pushing.

But it turns out that just when I was about to commit & push, I noticed that another teammate had made recently a push in the remote repo. Son now, the remote repo is one commit ahead from my local.

My attempted solutions:

  1. Whenever I try to push my changes, it says that it can't be possible because the remote repo is ahead. So I tried to force push my changes (my teammate and I agreed that I can do this), but the branch is protected by an administrator. I can't be done.

  2. Since that didn't worked, I tried to simply Pull the latest changes and updating recursively the submodules (submodule update --init -recursive). I'm getting the following error:

error: Your local changes to the following files would be overwritten by checkout

In Git Extensions output error window:

enter image description here

What would you do to solve this issue?

1

There are 1 answers

0
Jim Redmond On

git stash was made for this: it sets uncommitted changes aside until you're ready for them. You can use either git stash pop or git stash apply to put those changes back into your working directory after you've resolved your conflicts. (pop removes the stash from the list; apply does not.)

There's more documentation available at https://git-scm.com/docs/git-stash.