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

前端 未结 30 3448
失恋的感觉
失恋的感觉 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 11:58

    Just do

    git fetch origin branchname
    git checkout -f origin/branchname // This will overwrite ONLY new included files
    git checkout branchname
    git merge origin/branchname
    

    So you avoid all unwanted side effects, like deleting files or directories you wanted to keep, etc.

提交回复
热议问题