有推送git的排除文件等效物吗? [英] Is there an exclude file-equivalent for pushing in git?
问题描述
我使用排除文件来避免我在取出存储库时覆盖本地设置。我希望在推送到主存储库时不会推送相同的文件。我如何做到这一点?
I am using the exclude file to avoid my local settings from being overwritten when I pull a repository. I would like the same files to not be pushed when I push to the main repository. How do I do this?
推荐答案
如果一个文件被提交到您的本地存储库(您做过 git添加< file>
和 git commit
),然后如果您将此提交推送到任何其他存储库,您可以只推送整个提交,而不是单个文件。
If a file is committed to your local repository (you did git add <file>
and git commit
) then if you push this commit to any other repository that file will be pushed too. You can push only whole commits, not individual files.
如果您不想推送此文件,您必须先删除它,文件删除,并将其添加到.gitignore以避免再次提交。所以这样的步骤:
If you don't want to push this file, you have to first remove it, make a new commit with this file removed, and add it to .gitignore to avoid committing it again. So steps like this:
git rm yourfile
git commit -m 'Removing yourfile'
echo yourfile >> .gitignore
您完成了。
这篇关于有推送git的排除文件等效物吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!