When is git rm -f used?

后端 未结 3 505
暗喜
暗喜 2020-12-10 12:07

I am learning Git and am unable to understand under what condition the -f flag is used while issuing the \"git rm\" command. Please explain a scenario where rm -f would be r

3条回答
  •  忘掉有多难
    2020-12-10 12:43

    If you edit a file, and then realize you want to delete it instead.

    $ ls
    func.c
    $ vim func.c
    ...edit the file...
    

    Now that I think about it, I actually want to delete it...

    $ git rm func.c
    error: 'func.c' has local modifications
    (use --cached to keep the file, or -f to force removal)
    $ git rm -f func.c
    

提交回复
热议问题