简体   繁体   English

Git取消跟踪并推送

[英]Git untrack and push

Situation: I untrack some files keeping them locally. 情况:我取消跟踪某些文件,将它们保存在本地。 Files are removed from the index and kept in working tree. 文件从索引中删除并保留在工作树中。 Then I commit and push to remote. 然后我提交并推送到远程。 Files will be deleted from remote repository. 文件将从远程存储库中删除。

What will happen to other people when they pull? 别人拉时会发生什么? Will their local file be deleted (like remote) or will they keep their local copy, untracked (like my working tree)? 他们的本地文件将被删除(例如远程)还是将其本地副本保持未跟踪状态(例如我的工作树)?

If other people pull the branch locally then, their local files will be deleted like remote since the files are deleted from remote. 如果其他人在本地分支,则其本地文件将像远程一样被删除,因为这些文件是从远程删除的。


git rm --cached remove the file(s) from staging area, so the file(s) become untracked (not known/handle by git anymore). git rm --cached从临时区域中删除文件,因此该文件变得无法跟踪(git不再知道/处理)。 After Commit, Push the file is deleted from the remote. 提交后,“推”文件将从远程删除。

Like if you just create a new file a.txt but not Add, Commit, Push to remote (a.txt is a untracked file), then a.txt is totally unknown to other people when pulling locally. 就像您只是创建一个新文件a.txt而不是添加,提交,推送到远程文件一样(a.txt是未跟踪的文件),那么其他人在本地拉取时a.txt完全是未知的。

To start ignoring the changes to the file 开始忽略对文件的更改

git update-index --assume-unchanged path/to/file

To start keeping track again 重新开始追踪

git update-index --no-assume-unchanged path/to/file

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

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