简体   繁体   English

有人从git存储库中取消跟踪文件。 Git Kraken用户在提取最新提交时如何将文件保存在本地?

[英]Someone untracked a file from a git repo. How can the Git Kraken users keep the file locally when they pull the most recent commit?

I untracked a file from a git repo using git rm --cached myFile.txt 我使用git rm --cached myFile.txt从git repo git rm --cached myFile.txt跟踪文件

Using the command line, this is fine, myFile.txt is still there, now untracked. 使用命令行,这很好,myFile.txt仍然存在,现在未跟踪。 After pushing the commit, other users, who are using the Git Kraken GUI want to get the latest commit. 推送提交后,其他使用Git Kraken GUI的用户希望获取最新的提交。 However, Git Kraken shows myFile.txt as deleted, and when pulling, myFile.txt is deleted from their working directory. 但是,Git Kraken将myFile.txt显示为已删除,并且在提取时,myFile.txt从其工作目录中删除了。 How can they keep myFile.txt in their working directory, when the most recent commit removes that file? 最新提交删除该文件时,他们如何将myFile.txt保留在其工作目录中?

I can't figure out a way to keep the file locally using Git Kraken, but they can just open up git on the command line, but I am unsure which commands to use to keep the local file, and let it get untracked when they fetch or pull the latest commit. 我无法找到一种使用Git Kraken将文件保存在本地的方法,但是它们只能在命令行上打开git,但是我不确定要使用哪些命令来保存本地文件,并让它们在被跟踪时不被跟踪fetchpull最新提交。

From the standpoint of a user receiving changes, it appears that the next commit specifies "delete this file" as part of the next required change. 从接收更改的用户的角度来看,下一次提交似乎将“删除此文件”指定为下一个所需更改的一部分。 There isn't really a way, in the commit, to distinguish "untrack this file" as a separate type of change. 在提交中,实际上并没有办法将“取消跟踪此文件”作为一种单独的更改类型进行区分。

I assume you also added the file to .gitignore , by the way - and if you didn't, it seems like you'd want to in this situation. 我假设您还将该文件添加到了.gitignore ,如果没有添加,似乎在这种情况下就想这样做。 With that thought, I guess it might be nice if git could tell, for a deleted file, "hey, this commit also adds that path to .gitignore , so I'll assume they just mean to untrack it"; 有了这个想法,我想如果git可以告诉一个删除的文件,“嘿,这个提交也将路径添加到.gitignore ,所以我认为它们只是意味着要对其进行跟踪”,可能会很好。 but this would still be an assumption where git couldn't be sure, and in that context maybe it's for the best that the behavior is kept simple. 但这仍然是无法确定git的假设,在这种情况下,保持行为简单可能是最好的。 For better or for worse, that's how it's done. 无论好坏,这都是这样做的。

So basically each user pulling the commit in which you want to untrack the file is going to have to take some special steps to keep the file in (or get it back into) their work tree. 因此,基本上每个拉动您要在其中取消跟踪文件的提交的用户都将必须采取一些特殊步骤将文件保留在(或重新放入其)工作树中。

Now it seems likely that everyone has the same file, and it's the version that was in the commit just before you untracked it. 现在,似乎每个人都有相同的文件,而正是在取消跟踪之前,提交中的版本。 (Otherwise uncommitted local changes should be causing problems for each user.) In that case, you could do something like tag the last commit that had the file; (否则,未提交的本地更改会给每个用户造成问题。)在这种情况下,您可以执行类似标记带有文件的最后一次提交的操作; and then let everyone know that after a pull deletes the file, they should do something like 然后让所有人都知道,在请求删除文件后,他们应该执行以下操作

git checkout myTag -- myfile.txt
git rm --cached myfile.txt

On the other hand, maybe you're untracking the file because constant uncommitted local changes are causing problems for each developer. 另一方面,也许您正在取消跟踪文件, 因为持续不断的未提交的本地更改正在给每个开发人员带来问题。 In that case, you'd have to warn everyone in advance - "hey, next time you pull git will try to delete this file. If you have uncommitted changes it should throw a conflict. You'll need to move your file out of the way, let it finish checking out, and then put your file back" - at which point again I assume you'll have an ignore rule in place for it 在这种情况下,您必须提前警告所有人-“嘿,下次您拉git时,它将尝试删除此文件。如果您未提交更改,则会引发冲突。您需要将文件移出方式,让它完成检出,然后放回您的文件” –在这一点上,我再次假设您将有一个忽略规则

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

相关问题 在我拉出提交后,有人从远程存储库中删除了提交,如何在下一个git pull中将其保存在本地? - Someone removed a commit from remote repo after I pulled it, how do I keep it locally on the next git pull? 无法从 git 拉取或提交未跟踪文件 - Cant pull nor commit from git for untracked file 进行了git commit,git pull并将我的更改推送到了仓库。 我如何发送对我提交的请求的请求 - did a git commit, git pull and pushed my changes to the repo. How can i send a Pull request for the one that i committed 从 git 中删除文件,但将其保留在 git pull 本地? - Remove a file from git, but keep it locally on git pull? 无法提交git repo。 Pathspec'origin'与git已知的任何文件都不匹配 - Unable to commit to git repo. Pathspec 'origin' did not match any file(s) known to git 如何找到修改文件的最新 git commit? - How do I find the most recent git commit that modified a file? 如何在本地提交Git文件? - How to commit a Git file locally? 如何从 GIT Repo 读取文件数据。 无需使用 JGIT API 在本地克隆它 - How to read the file data from GIT Repo. without cloning it in local using JGIT API git,尝试从远程提取特定提交,而不是最近提交 - git, trying to pull a specific commit from remote, not the most recent one 如何在 git 存储库中仅为部分用户提交文件? - How do I commit a file for only some users in a git repo?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM