简体   繁体   English

从未检出的Git分支中删除文件?

[英]Remove files from a Git branch that is not checked out?

Is it possible to remove files from a Git repository branch, while another branch is checked out? 当另一个分支被检出时,是否可以从Git存储库分支中删除文件?

I'd like to do this in order to resolve some conflicts with files that are .gitignore'd in the checked out branch but still in the repository for a branch I want to check out. 我想这样做是为了解决与.gitignore在检出的分支中存在但仍在我要检出的分支的存储库中的文件产生的一些冲突。 Caused by some hasty decissions while setting up a git repository for inherited code in Netbeans. 在NetBeans中为继承的代码设置git存储库时,由于某些仓促决定而引起的。

Wile technically it's possible to replace the tip commit on a branch with another one, you'll have to cook it programmatically which is more hassle than you're trying to avoid. 从技术上讲,可以将一个分支上的tip提交替换为另一个,您必须以编程方式对其进行烹饪,这比您尝试避免的麻烦更多。

So another option would be to do that manually using a separate work tree and an index. 因此,另一种选择是使用单独的工作树和索引来手动执行此操作。 This article explains how to do that. 本文介绍了如何执行此操作。 Basically, you check out that branch to a separate work tree (and possibly using a separate index), and fix up the offending commit. 基本上,您可以将该分支检出到单独的工作树(并可能使用单独的索引),并修复有问题的提交。

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

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