Git删除供应商中的文件

时间:2018-03-10 04:50:25

标签: git

我需要在git中跟踪我的供应商目录中的文件。我知道这不常见,但我必须将所有内容作为单个软件包提供给隔离网络。这是客户的要求。无论如何,我已经出售了16个依赖项。十四个正在按照我的预期工作。两个依赖关系将不会停留。这不是.gitignore的结果。我已从依赖项中删除了.git目录。我正在使用git版本2.1.2。但是,git只会将文件添加到repo中。有什么建议吗?

1 个答案:

答案 0 :(得分:0)

我解决了这些问题。首先,我运行了以下代码:

for X in `find /projects/go/src/c2s/vendor -type f`
do
    git add --force $X
done

这适用于2个问题儿童中的一个。第二个产生了以下错误:

fatal: Pathspec '/projects/go/src/c2s/vendor/github.com/Shopify/sarama/.travis.yml' is in submodule 'vendor/github.com/Shopify/sarama'
fatal: Pathspec '/projects/go/src/c2s/vendor/github.com/Shopify/sarama/CHANGELOG.md' is in submodule 'vendor/github.com/Shopify/sarama'
...
...
fatal: Pathspec '/projects/go/src/c2s/vendor/github.com/Shopify/sarama/LICENSE' is in submodule 'vendor/github.com/Shopify/sarama'
fatal: Pathspec '/projects/go/src/c2s/vendor/github.com/Shopify/sarama/Makefile' is in submodule 'vendor/github.com/Shopify/sarama'

我发现Removing Submodules给出了以下指示:

Delete the section referring to the submodule from the .gitmodules file
Stage the changes via git add .gitmodules
Delete the relevant section of the submodule from .git/config.
Run git rm --cached path_to_submodule (no trailing slash)
Run rm -rf .git/modules/path_to_submodule
Commit the changes with ```git commit -m "Removed submodule "
Delete the now untracked submodule files rm -rf path_to_submodule

然后我再次将我的脚本放在上面,一切都卡住了!