Deleting Files using Git/GitHub

前端 未结 4 899

First off, I\'m new to Git.

I deleted a bunch of files locally on my Mac using Finder. I want the files that I deleted to no longer show in the current branch, but t

4条回答
  •  情歌与酒
    2020-12-12 09:17

    You can see deleted files, which are still 'tracked' with:

    git ls-files --deleted
    

    To delete files from a branch, you can do something like this:

    git ls-files --deleted -z | xargs -0 git rm
    

    From man git-rm:

    Remove files from the index, or from the working tree and the index. git-rm will not remove a file from just your working directory. (There is no option to remove a file 13 only from the work tree and yet keep it in the index; use /bin/rm if you want to do that.)

    Finally, to commit the "removal" do something like:

    git commit -m "removed some files"
    

提交回复
热议问题