Can't do a git pull

后端 未结 5 1137
再見小時候
再見小時候 2021-01-31 07:11

I\'m trying to do a git pull and get the error message:

error: The following untracked working tree files would be overwritten by merge:


        
相关标签:
5条回答
  • 2021-01-31 07:43

    You have untracked files in the way of the pull. You can't remove them with git rm --cached because they are untracked. They don't appear in the index. You need to remove them with plain old rm

    0 讨论(0)
  • 2021-01-31 07:49

    This is an opportunity for the 'git clean' command. If you don't care about the untracked files ... git clean -n to see what will be removed, and git clean -f to go ahead and rm untracked files.

    Add -d to the commands to also operate on directories:

      git clean -dn
      git clean -df
    
    0 讨论(0)
  • 2021-01-31 07:53

    That file isn't in the current branch yet, so you can't remove it with git rm --cache. Just use rm.

    0 讨论(0)
  • 2021-01-31 07:54

    As it says in the original error message, that file is untracked. That means git doesn't know anything about it. Just remove it from the filesystem using rm. If you care about the contents, just move it somewhere else.

    0 讨论(0)
  • 2021-01-31 08:00

    I agree with other posters, the issue is that the file isn't being tracked by git. the command git rm works on files being tracked. rm will remove the file from your machine. Alternatively you could add the file to your list of ignored files, or file types if that is convenient. You could also use one of the GUI tools like tortoise git to quickly delete all untracked files.

    0 讨论(0)
提交回复
热议问题