I am having a bit of a trouble with my Git.
Here is the preface: a couple days ago I made a few commits and pushed them to the Github remote. It turned out that some of these features interfered with those of another developer. Hence, she reverted 3-4 of my commits so she could test her feature.
Now the story. Today I made a couple more changes and commits locally. When I went to push them, I was told that remote is different and I need to use the merge tool. I did (the changes were minor and trivial). Then, I made a merge commit. The problem with this commit is that it completely overrides the local changes I made. Having asked in another thread, I used git reset --hard <commit number>
to get back to my working code. From now on, no matter what I try to do, I keep getting my code overwritten by the remote version.
Why does this keep happening and how can I resolve it? I basically want to make sure my local is up-to-date with remote and that I can push my changes to remote.
Edit:
After I do git reset --hard
and try to do git push origin <commit number>:<remote branch name>
, I get the following error:
error: failed to push some refs to
'https://github.com/xxx/xxx.git' hint: Updates were
rejected because the tip of your current branch is behind hint: its
remote counterpart. Integrate the remote changes (e.g. hint: 'git pull
...') before pushing again. hint: See the 'Note about fast-forwards'
in 'git push --help' for details.