Through a reset to an earlier commit, I cannot get my local branch back in order. I keep getting merge conflicts locally, while the version on remote does not have any conflicts and what I want, is to get an exact copy of the fremote in my local branch.
What I can do is git checkout <last commit>
and I will essentially get a copy of the remote in my local directory but then I also get:
$ git checkout bd8b876
Note: checking out 'bd8b876'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
Which I don't want, as I still need to work on this branch.
I prefer not to start a new branch as the branch name is tied in with a script that is linked to the JIRA ticket too. If there's no other way though, I will do that.
What I've tried to resolve the issue:
git reset --hard HEAD
is now at 8dc6510 Update main.py
git status
On branch OS-4055-header_bar_Drive_parameters
Your branch and 'origin/branch' have diverged,
and have 19 and 3 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
nothing to commit, working directory clean
but this would always leave my local files in a merged state. I figured that pull
in a combination of fetch
and merge
.
I also tried (after reset): $ git fetch origin branch:branch
but even that would not give me the expected result. I checked the branch out on another syste and the files came in as expected (w/o merge conflicts). How do I get my local branch working copy into that state without the need to entirely delete my source directory?
`