首页 > 其他 > 详细

git远端删除被提交后又被加到.gitignore的文件

时间:2014-02-15 02:33:23      阅读:394      评论:0      收藏:0      [点我收藏+]

远端删除文件而不影响本地文件

git rm [-r] --cached file_or_dir_name

利用.gitignore来自动删除所有匹配文件

我试过网上推荐的写法
git rm --cached git ls-files -i --exclude-from=.gitignore git
commit -m ‘Removed all files that are in the .gitignore‘
git push origin master
--exclude-from=.gitignore顺便可以简写成-X .gitignore,所以是这样:
git rm --cached git ls-files -i -X .gitignore
但没成功,有人这样写,我没测试,这是先删除再提交的做法:
git rm -r --cached .
git add .
git commit -m ‘Removed all files that are in the .gitignore‘
git push origin master
如果用powershell:
($i in iex ‘git ls-files -i -X .gitignore‘) { git rm --cached $i }
测试通过

参考: http://stackoverflow.com/questions/7927230/remove-directory-from-remote-repository-after-adding-them-to-gitignore

git远端删除被提交后又被加到.gitignore的文件

原文:http://www.cnblogs.com/walkerwang/p/3549367.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!