如何从远程git存储库中删除文件?我有一个刚从工作副本本地存储库中删除的文件,我想从相应的远程存储库中删除它
Answers:
如果您从工作树中删除了文件,则提交删除:
git commit -a -m "A file was deleted"
并将您的提交推向上游:
git push
.gitignore。现在,将文件移出或删除到分支中不再需要的源树中。然后执行:git add .,git status(以进行审核),,git commit -m "removed files X,Y,Z"然后将它们添加回您的目录中,.gitignore这样它们就不会再潜入您的源代码中了。
使用命令:
git rm /path to file name /
其次是
git commit -m "Your Comment"
git push
您的文件将从存储库中删除
-r选项进行递归。因此,该命令将看起来像 git rm -r /path-to-file-name/然后执行上面的答案中提到的commit和push。
git add 'deleted file name'
git commit -m'message'
git push -u origin branch
git rm 'file name'
git commit -m'message'
git push -u origin branch
git rm --cached 'file name'
git commit -m'message'
git push -u origin branch
更简单的方法
git add . -A
git commit -m "Deleted some files..."
git push origin master
-A更新索引,不仅在工作树具有文件匹配的地方,而且在索引已经具有条目的地方。这将添加,修改和删除索引条目以匹配工作树。取自(http://git-scm.com/docs/git-add)
如果您在文件或文件夹进入.gitignore(或没有.gitignore)之前将其推送:
如果您删除了很多文件和文件夹,请执行此操作
git commit -a -m .
git push
git commit(具有要删除路径的文件名)-m“文件已删除”
git推
它将起作用。多个选择文件也可以用相同的方式在远程存储库中删除。
git commit -am "A file was deleted"