如何从git仓库合并后删除.orig文件?

一些如何.orig文件在合并期间在我的git仓库中被检查,现在显示在已修改和未被跟踪的扇区中。 但我不希望这个文件在我的仓库中。 怎么做。

modified: Gemfile.lock.orig # modified: Gemfile.orig # modified: app/assetshttp://img.dovov.combg_required.png.orig # modified: app/assets/javascripts/application.js.orig etc... 

任何帮助将不胜感激。

在这种情况下最好的解决scheme是保持简单,摆脱那些独立于git的文件:

 cd /your/repo/directory find . -name '*.orig' -delete 

尝试git clean更多信息,你可以在这里或这里find

你可以做:

 git config --global mergetool.keepBackup false 

有关更多信息,请参阅Git mergetool生成不需要的.orig文件

您可以使用.gitignore忽略文件

只需将* .orig放置在列表中,如下所示

https://help.github.com/articles/ignoring-files

为了删除当前文件,你可以创buildshell脚本并像下面这样从项目文件夹运行

 for file in `find *.orig -type f -print` do echo "Deleting file $file" git rm $file -f done 

git rm Gemfile.lock.orig和其他不需要的文件。 git commit --amend

要彻底删除这些blob, git gc --prune=0 --aggressive

git rm <file>

http://git-scm.com/docs/git-rm

还要添加你想忽略的文件/目录到你的.gitignore文件。