Git. Restart the local branch on top of the local master. How to ignore individual file changes?

With Git I'm on a branch. I reload the branch on top of the master. There is a conflict that I want to resolve by ignoring the branch version and accepting the main version. How to indicate that I want to use the main version of the file during reboot.

Thanks,
Doug

+5
source share
3 answers

git checkout --ours <path-to-file> is the command you are looking for.

It will check the main version of the file, which you can then add to the index (to mark a conflict resolved) and continue with your rebase.

You can find more detailed information in the documentation for verification .

See the comment in the --merge section for why you need to use --ours rather than --theirs .

+7
source

Just in case, when someone cares for me.

If you want to override all your local changes with yours, it's probably because someone deleted the commit that your local branch referenced and added a new one and you do rebase, so git tries (this old commit + yours) on top of mine.

In this case, use git rebase -i remote-branch and comment out the old commit.

Hope this helps.

+1
source
0
source

Source: https://habr.com/ru/post/1203298/


All Articles