简体   繁体   English

使用IntelliJ和Git切换分支

[英]Switching branches with IntelliJ & Git

this should be an easy one... 这应该是一个简单的...

I'm trying IntelliJ (came from Eclipse) and I have this issue that I don't know how to handle, I have configured my project using the branchA no problems, but, as soon a try to checkout another branch branchB the IDE tells me that fails due some untracked file that will get overwrite. 我正在尝试IntelliJ(来自Eclipse),但有一个我不知道如何处理的问题,我已经使用branchA配置了项目,但没有问题,但是,一旦尝试签出另一个分支BranchB ,IDE就会告诉我我失败,因为一些未跟踪的文件将被覆盖。

The file is vcs.xml :S 该文件是vcs.xml:S

If I delete it as the IDE recommends I lose the ability to switch branches. 如果我按照IDE的建议将其删除,则会失去切换分支的能力。

I'm not sure what I'm missing or how do I have to configure the project so I can switch branches normally. 我不确定要丢失什么,或者我必须如何配置项目才能正常切换分支。

Any help will be appreciated, thanks. 任何帮助将不胜感激,谢谢。

Looks like you need to do two things 看来您需要做两件事

1) remove .idea/vcs.xml file from your Git repository 1)从您的Git存储库中删除.idea / vcs.xml文件

2) exclude it in .gitignore so you will not check this file in anymore. 2)将其排除在.gitignore中,因此您将不再检查该文件。 It is usually stored under /.idea/. 它通常存储在/.idea/下。 This particular one can be done with 这个特殊的可以用

 .idea / vcs.xml

You should not check this file inside Git repository as the others suggest. 您不应像其他人建议的那样在Git存储库中检查此文件。 Otherwise another IntelliJ user of the Git repo will overwrite his settings of vcs. 否则,Git存储库的另一个IntelliJ用户将覆盖他的vcs设置。

You can go on VCS > Git > Commit. 您可以进入VCS> Git>提交。 There you can toggle the unversioned file and toggle the checkbox, commit and your file is in the vcs. 在这里,您可以切换未版本控制的文件,并切换复选框,提交和文件在vcs中。

You need to add the untracked branch to git. 您需要将未跟踪的分支添加到git中。 From the command line it would be: 从命令行可以看到:

git add <file name>
git commit -m "Your message here"

In the IDE, find the file in the project tree-view, right-click, and select Git -> Add (or press Ctrl-Alt-A). 在IDE中,在项目树视图中找到文件,右键单击,然后选择Git-> Add(或按Ctrl-Alt-A)。 Then to commit, Ctrl-K. 然后提交,Ctrl-K。

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

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