在 Eclipse 上更改 git 分支

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24650027/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:16:49  来源:igfitidea点击:

Changing the git branch on eclipse

eclipsegitspring-tool-suite

提问by user3242743

This is the first time I do this. I imported a git project in eclipse. Then I used the shell to create another branch and checkout to the new branch.

这是我第一次这样做。我在eclipse中导入了一个git项目。然后我使用 shell 创建另一个分支并结帐到新分支。

Is refreshing the imported project in Eclipse enough to tell Eclipse that we are working on the new created branch?

在 Eclipse 中刷新导入的项目是否足以告诉 Eclipse 我们正在处理新创建的分支?

thanks

谢谢

回答by love

Right-click your project and select TeamBranchto create new branches or to switch between existing branches. You can also switch branches in the History view.

右键单击您的项目并选择团队分支以创建新分支或在现有分支之间切换。您还可以在历史视图中切换分支。

回答by Kris

Actually, I don't think you even need to refresh the project. That is, assuming you have 'eGit' installed and your projects are already configure as git projects (they should be, because in most cases, egit does that automatically).

实际上,我认为您甚至不需要刷新项目。也就是说,假设您已经安装了“eGit”并且您的项目已经配置为 git 项目(它们应该是,因为在大多数情况下,egit 会自动执行此操作)。

Whenever you run git commands on the shell (outside eclipse) egit will automatically refresh projects for you and update their status when you switch back to Eclipse.

每当您在 shell 上运行 git 命令时(在 eclipse 之外),egit 将自动为您刷新项目并在您切换回 Eclipse 时更新它们的状态。

If you are not using egit then yes, you have to refresh the projects manually, but that is all you'd have to do since running the 'git checkout my-branch' command in the shell already changed the files on disk to be those from 'my-branch'.

如果您没有使用 egit 那么是的,您必须手动刷新项目,但这就是您必须做的所有事情,因为在 shell 中运行“git checkout my-branch”命令已经将磁盘上的文件更改为那些来自“我的分支”。

回答by himani1349

Actually when you are working with eclipse, eGit is a very cool tool integrated inside eclipse, which lets you do all git stuff, like

实际上,当您使用 Eclipse 时,eGit 是集成在 Eclipse 中的一个非常酷的工具,它可以让您执行所有 git 操作,例如

  1. git checkout to a new branch
  2. git create new branch
  3. git stash
  4. even view your unstaged changes(select files and avoid complexities caused by git add .)
  5. and finally commit.
  1. git checkout 到一个新的分支
  2. git 创建新分支
  3. 混帐
  4. 甚至查看您未暂存的更改(选择文件并避免由 git add 引起的复杂性。)
  5. 最后提交。

Read here to know more. Eclipse Egit user guideSo you get to do all version repository stuff at one place as you code.

阅读此处了解更多信息。Eclipse Egit 用户指南因此,您可以在编写代码时在一处完成所有版本存储库的工作。

Git Repository view in Eclipse

Eclipse 中的 Git 存储库视图

So to answer your question, yes as you checkout a new branch even in a shell/command prompt your changes will be reflected in eclipse.

因此,要回答您的问题,是的,即使在 shell/命令提示符中签出新分支时,您的更改也将反映在 eclipse 中。