Git not removing files when switching branch

后端 未结 3 1770
半阙折子戏
半阙折子戏 2020-12-04 17:40

Sometimes when switching branches using Git (version 1.7.2.1) it does not seem to remove the files/directories I created specific to the branch I switched away from. Neither

相关标签:
3条回答
  • 2020-12-04 18:01

    I have seen this too. I usually just do a git reset --hard followed by a git clean -f -d and it usually does the trick.

    It seems to definitely happen the most often when my IDE has a lock on one of the files in the branch i'm switching from.

    0 讨论(0)
  • 2020-12-04 18:04

    I had the same problem because I did not commited files before switching branch !

    More explanations here : Why git keeps showing my changes when I switch branches (modified,added, deleted files) no matter if I run git add or not?

    0 讨论(0)
  • 2020-12-04 18:18

    First:

    git reset --hard
    

    Reset the repository to the state of the last commit.
    Since git normally does not remove files it is not tracking those could still cause issues.

    Then:

    git clean -d --dry-run
    

    See what files would get deleted. We don't want to loose valuable work. and if that is ok:

    git clean -d
    
    0 讨论(0)
提交回复
热议问题