Resolve merge conflicts: Force overwrite all files

后端 未结 2 973
野趣味
野趣味 2021-01-30 07:08

I am working on a git repository by myself (so yes, I know the implications and the warnings of doing this) and somehow one of the trees got a commit after being pushed

2条回答
  •  孤街浪徒
    2021-01-30 07:18

    There are three simple solutions to copy the last version that is in you remote repository, discarding all changes that you have made locally:

    1. Discard your repository and clone again. This is the most simple solution, but if your repository is big, it can take a long time, and may require extra effort like reconfigureing, etc.

    2. Discard the local changes with git reset --hard and then do a git pull. The problem is you need to first find a commit that precedes whatever change history you are trying to avoid. After resetting to that commit hash, do a git pull.

    3. Do a git fetch to bring the updates to your local reference of the remote branch (usually origin/master) and then do a git reset --hard passing this reference, ie, git reset --hard origin/master.

提交回复
热议问题