Warm tip: This article is reproduced from serverfault.com, please click

Git merge conflicts,unable to push or pull code from master

发布于 2020-11-27 19:54:54

I’m stuck at this point where me and my teammate working on the master branch and we both pushed the code but I didn’t pull the changes and again pushed the code so here i’m now I can’t pull or push the code.. what should i do?

Questioner
mehroz rj
Viewed
0
Mahmoud K. 2020-11-28 08:38:50

This might look intimidating but bare with me:

  1. Get the hash of the stable common commit between you and master: git log
  2. Soft reset your commits to convert them to unstaged changes. : git reset --soft [hash]
  3. Stash you current working changes: git stash
  4. Fetch latest changes from remote: git fetch
  5. Pull latest changes from remote: git pull
  6. Bring back your work from the stash: git stash apply or git stash pop
  7. Resolve any conflicts and recommit your work: git commit ...
  8. Push your changes to remote: git push

From now own, you should remember to do all your work on a separate branch and then merge them onto master.