I have a merge conflict in the files. So i have to remove everything which is above the master from both local and remote.Please see the image. how do I do it. I am not sure how git reset --hard will work.
1 Answers
If you are positive that you must remove your changes following your master
and origin/master
branch, then indeed, you can use git reset --hard
.
You can do the following:
# Go to your branch
git checkout Release_ABCDEFG_W48.new
# Reset your Release branch to the point where master is, thus DESTROYING your work
git reset --hard master
If you don't want to loose your changes, you can use the --soft
option to git reset
. The documentation states:
--soft. Does not touch the index file or the working tree at all (but resets the head to , just like all modes do)
Once you are doing deleting your work, you just have to push --force
to your remote so that it can reflect your local changes.
Sorry for stressing out so much that you would loose work by this method, but it is a real danger. Be sure you want to do this.
An alternative approach is to rename your branch, move it to somewhere else, or at least back-up (in worst scenario if you can't do it with git) your work, so that you don't loose. You always have the reflog
to save you, but better not mess with that.

- 4,116
- 2
- 14
- 24