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

前端 未结 30 3835
失恋的感觉
失恋的感觉 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:14

    WARNING: git clean deletes all your untracked files/directories and can't be undone.


    Sometimes just clean -f does not help. In case you have untracked DIRECTORIES, -d option also needed:

    # WARNING: this can't be undone!
    
    git reset --hard HEAD
    git clean -f -d
    git pull
    

    WARNING: git clean deletes all your untracked files/directories and can't be undone.

    Consider using -n (--dry-run) flag first. This will show you what will be deleted without actually deleting anything:

    git clean -n -f -d
    

    Example output:

    Would remove untracked-file-1.txt
    Would remove untracked-file-2.txt
    Would remove untracked/folder
    ...
    

提交回复
热议问题