1

I want to override a specific branch that im currently in, in order to override/replace everything from the remote repository server.

If i do git pull on that branch i always get a merge conflict because both files are changed, and i cant get it merged right (no mergetool) and i want to avoid any commits that are unneccesary, especially from this server becaue its only a preview server.

I edited the file already and add/ commit the file again, but no success. So i rolled back with git reset --hard <sha1> to the last real commit. Hope that wa sok to do so?

  • Yes, what you are doing is ok. You can follow this link to understand better. http://stackoverflow.com/questions/1125968/force-git-to-overwrite-local-files-on-pull – chanchal118 Mar 29 '14 at 08:45
  • i tried git fetch --all, now git status tells me im behind 22 commits. But of what 22 commits if i pull everything from remote shouldnt it be up2date? – user2370234 Mar 29 '14 at 08:55
  • You rolled back your local tree, so yea it should say you're behind because the remote tree wasn't rolled back too. – Mohammad AbuShady Mar 29 '14 at 09:25

1 Answers1

0

Your approach is for fixing a file.

To reset tour branch, you can simply fetch, and reset it to the remote branch:

git checkout yourBranch
git fetch
git reset --hard origin/anotherBranch

YourBranch will now refer to the same commit as origin/anotherBranch.
(Depending on what branch you want, YourBranch and origin/anotherBranch could have the same name)

Make sure you don't have any work in progress (as the reset --hard would delete that)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250