使用未提交的自动生成的更改切换 GIT 中的分支
我正在尝试切换 GIT 中的本地分支,但一些自动生成的、忽略的和未提交的文件阻止了它。有没有办法让这些文件不阻止我切换分支?
我有一个共同的工作流程。我有一个开发分支,其中有一些我从源代码本地生成的 .class 文件。 .class 文件不在存储库中,它们将被忽略。当我更新本地开发分支时,我生成所有类文件。一切都很好。
当我尝试切换分支时,我会收到关于这些类文件中所有未提交的更改的警告。我可以通过使用强制开关从命令行切换分支来解决这个问题,但这看起来很愚蠢。有什么办法让 GIT 知道它真的不应该关心这些文件/文件夹吗?
我的团队正在使用 Eclipse 和 Egit。任何帮助将不胜感激。
谢谢, 大卫·R
I'm trying to switch local branches in GIT but some auto-generated, ignored and uncommitted files are preventing it. Is there a way to have these files not prevent me from switching branches?
I have a common workflow. I have a development branch which has some .class files that I generate locally from source. The .class files are not in the repo and they are ignored. When I update my local development branch I generate all the class files. Everything is good.
When I try to switch branches I get warned about all my uncommitted changes in these class files. I can get around this by switching branches from the command-line with the force switch but this seems silly. Is there any way to let GIT know it really shouldn't be concerned with these files / folders?
My team is using Eclipse and EGit. Any help would be appreciated.
Thanks,
David R
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的其他分支可能已经提交了这些内容,这些内容将与您工作目录中的内容发生冲突。您可以执行以下两件事之一:
或
Your other branch probably has those committed and these will clash with what you have in your working dir. You can do one of 2 things:
or
如果您确实不想提交这些文件,请将它们添加到本地 .gitignore 文件中。
在 python 项目中,我的 .gitignore 看起来像这样:
还有一个流行的 git 树适用于各种编程语言和环境的 .gitignore 文件。
如果您想保留您的工作,但跳到另一个分支,也许是为了快速发布错误修复版本,
git 存储
是你的朋友吗?
将保存存储并允许您切换分支
将列出各种存储
将恢复存储
If you really don't want to be committing these files, add them to a local .gitignore file.
On a python project, this is what my .gitignore looks like this:
There is also a git tree of popular .gitignore files for various programming languages and enviroments.
If you want to retain your work but hop of to another branch perhaps to do a quick bug-fix release,
git stash
is your friend there.
will save the stash away and allow you to switch branches
will list the various stashes
will restore a stash
请注意,那些未提交的文件仍然是一个问题,最近的 EGit2.0 现在< a href="http://wiki.eclipse.org/EGit/New_and_Noteworthy/2.0#Stash_Support" rel="nofollow noreferrer">支持隐藏。
分支结果对话框中有一个新的存储选项。
这允许快速隐藏任何阻止分支检出的冲突更改。
Note that is those uncommitted files are still an issue, the recent EGit2.0 now supports stash.
And there is a new stash option in branch result dialog.
This allows to quickly stash any conflicting changes that are preventing a branch from being checked out.