简体   繁体   English

Git-如何取消跟踪本地文件,然后将本地推送到远程分支?

[英]Git - How to untrack local files and then push local to remote branch?

On the local side I began tracking all files in my project and removed many of my gitignore restrictions. 在本地方面,我开始跟踪项目中的所有文件,并删除了许多gitignore限制。 Due to Git size restrictions and the fact that many of these files are static (images, etc..) I've since decided against pushing all files. 由于Git大小的限制,而且其中许多文件都是静态文件(图像等),因此我决定不推送所有文件。 No matter what I do with gitignore, when I prepare to commit and push, all of the files are still being tracked and compiled for syncing. 无论我使用gitignore做什么,当我准备提交和推送时,所有文件仍在跟踪和编译以进行同步。

I don't want to remove the files so git rm is out of the question. 我不想删除文件,因此git rm完全没有问题。

git rm --cached stops tracking the files you give to it without physically deleting them. git rm --cached停止跟踪您提供给它的文件,而不会实际删除它们。

Note, though, that this will not shrink your repository's size, since the files will remain in the history. 但是请注意,这不会缩小存储库的大小,因为文件将保留在历史记录中。 Also, even if you have large files in your repository, they will not cause your repository size to grow over time as long as you don't make changes to them. 同样,即使您的存储库中有大文件,只要您不对其进行更改,它们也不会导致存储库大小随时间增长。 The time required to push the large files will also be a one-time cost; 推送大文件所需的时间也将是一次性的费用。 subsequent pushes (that don't touch the large files) will be fast. 随后的推送(不触摸大文件)将很快。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM