本地git文件手动删除后实现线上git仓库也移除该文件

it2023-11-12  71

正常git命令删除文件

git rm命令删掉要删除的文件 删除掉,我们要把这次操作提交到上去,git commit -m “for test”

git rm 文件名 git commit -m "for del" git push

非正常git命令删除文件

1、当本地仓库文件并非按照git命令正常删除,而是手动对文件或文件夹进行删除时git status会出现以下提示

git status # On branch master # Changes not staged for commit: # (use "git add/rm <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # deleted: www.message.com.zip # no changes added to commit (use "git add" and/or "git commit -a")

解决办法:执行以下命令实现删除本地仓库记录,同时删除线上文件

git add -A . git commit -m 'del file' git push
最新回复(0)