Adding file to git's stage does nothing and cannot be committed

前端 未结 2 1814
清歌不尽
清歌不尽 2021-02-05 03:32

I have gotten myself into a bizarre situation where in one of my branches a web.config file cannot be added to the stage. The output of

git add path/to/web.confi         


        
2条回答
  •  半阙折子戏
    2021-02-05 04:04

    Typically when git gets into a confused state, removing and re-adding the file to the cache will fix it:

    git rm --cached foo
    

    It seems the most common way that a file gets in the confused state, is when performing a mv from the command line.
    I've found that using git mv instead of mv helps to prevent running into this issue. http://linux.die.net/man/1/git-mv

    Lastly, If you are going to delete a file from a git repository, use git rm instead of just rm
    Why use 'git rm' to remove a file instead of 'rm'?

    https://www.kernel.org/pub/software/scm/git/docs/git-rm.html`

提交回复
热议问题