How do I force “git pull” to overwrite local files?

前端 未结 30 3434
失恋的感觉
失恋的感觉 2020-11-21 11:35

How do I force an overwrite of local files on a git pull?

The scenario is the following:

  • A team member is modifying the t
30条回答
  •  再見小時候
    2020-11-21 12:07

    I believe there are two possible causes of conflict, which must be solved separately, and as far as I can tell none of the above answers deals with both:

    • Local files that are untracked need to be deleted, either manually (safer) or as suggested in other answers, by git clean -f -d

    • Local commits that are not on the remote branch need to be deleted as well. IMO the easiest way to achieve this is with: git reset --hard origin/master (replace 'master' by whatever branch you are working on, and run a git fetch origin first)

提交回复
热议问题