gitgit-reset

Wrong git commit to trunk in local, how to pull clean from remote?


After doing some changes I committed them locally to the trunk before branching. I then branched and pushed my changes to the remote repository. Now the remote repository has the changes it needs to have. However, because of my local commit to trunk I get the following message when trying to pull recent changes from the remote trunk: hint: You have divergent branches and need to specify how to reconcile them.

I have seen this question How to git pull while ignoring local changes? and I performed the following commands suggested in the answer:

git reset --hard
git pull

However, I'm still getting the same message.

What did I try and what was I expecting?
I would like to have my local trunk up to date with remote, and I would like the remote to overwrite all the changes I might have locally.


Solution

  • This is the specific command that resets the local trunk and let the local pull an up-to-date version of the remote trunk, without considering the local changes:

    git reset --hard origin/{trunkName}