1

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?

mehroz rj
  • 13
  • 3

2 Answers2

2

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.

Mahmoud
  • 9,729
  • 1
  • 36
  • 47
0

Checkout a new branch.

git checkout -b tmp

Delete your current master.

git branch -D master

Checkout master from origin

git checkout master

Merge your branch and handle conflicts

git merge tmp

wickdninja
  • 949
  • 1
  • 10
  • 15