The following untracked working tree files would be overwritten by merge, but I don't care

前端 未结 16 1020
挽巷
挽巷 2020-12-02 03:37

On my branch I had some files in .gitignore

On a different branch those files are not.

I want to merge the different branch into mine, and I don\'t care if t

相关标签:
16条回答
  • 2020-12-02 03:51

    Remove all untracked files:

    git clean  -d  -fx .
    

    Caution: this will delete IDE files and any useful files as long as you donot track the files. Use this command with care

    0 讨论(0)
  • 2020-12-02 03:52

    You can try that command

    git clean -df
    
    0 讨论(0)
  • 2020-12-02 03:53

    If you have the files written under .gitignore, remove the files and run git pull again. That helped me out.

    0 讨论(0)
  • 2020-12-02 03:54

    One way to do this is by stashing you local changes and pulling from the remote repo. In this way, you will not lose your local files as the files will go to the stash.

    git add -A
    git stash
    git pull
    

    You can check your local stashed files using this command - git stash list

    0 讨论(0)
  • 2020-12-02 03:55

    If this is a one-time operation, you could just remove all untracked files from the working directory before doing the pull. Read How to remove local (untracked) files from the current Git working tree? for information on how to remove all untracked files.

    Be sure to not accidentally remove untracked file that you still need ;)

    0 讨论(0)
  • 2020-12-02 04:00

    Neither clean/reset/hard checkout/rebase worked for me.

    So I just removed files that git complained about*

    rm /path/to/files/that/git/complained/about
    

    *I checked if this files can be removed by checking out a brand new repo in a separate folder (files were not there)

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