在Eclipse Che中如何切换Git分支

huangapple go评论69阅读模式
英文:

How to switch git branch in Eclipse Che

问题

我最近发现了 Eclipse Che(在 Red Hat 的 CodeReady Toolchain 上),并且已经在一个 Java 开发项目中使用它。

我将所有的代码放在 Gitlab 中,所以我只需创建一个新项目,并从那里加载所有内容。

现在,是否有一种在 Eclipse Che 内为该项目切换 git 分支的方法?

到目前为止,我找到的解决方法有以下之一:

  • 编辑该项目的 Devfile 并修改分支名称:

在Eclipse Che中如何切换Git分支

  • 添加第二个项目,具有相同的细节,但分支名称不同。

肯定有其他方法可以做到这一点,只是我没有发现而已。

我已经在“源代码控制”中检查了不同的选项,但仍然找不到进行此操作的选项。

提前感谢!

英文:

I've recently discovered Eclipse Che (on Red Hat's CodeReady Toolchain) and been using it for a development project in Java.

I have all my code in Gitlab, so I simply created a new project and loaded everything from there.

Now, is there a way to switch git branches for that project within Eclipse Che?

The only workarounds I've found so far is by doing one of these:

  • Edit the Devfile for that project and modify branch name:

在Eclipse Che中如何切换Git分支

  • Add a second project with same details, but different branch name.

There must be some other way to do this and I'm just missing it.

I've already checked the different options in "Source control" and yet, I couldn't find an option to do this.

Thanks in advance!

答案1

得分: 2

Che使用vscode Git扩展作为源代码管理(SCM)提供程序,您可以在此处找到有关vscode Git检出命令的文档:https://code.visualstudio.com/docs/editor/versioncontrol#_branches-and-tags,这对于Che也是相关的。

要快速检出一个分支,您可以点击左下角的分支指示器:

在Eclipse Che中如何切换Git分支

您将看到一个带有分支的下拉列表。

英文:

Che uses vscode Git extension as an SCM provider, you can find the documentation about the vscode Git checkout command here: https://code.visualstudio.com/docs/editor/versioncontrol#_branches-and-tags, which is also relevant for Che.

To quickly checkout a branch you can click the branch indicator in the left bottom corner:

在Eclipse Che中如何切换Git分支

You will see a drop-down list with branches.

答案2

得分: 0

我不知道你如何与 Che 一起工作。但就我所知,每次我处理新任务/问题时,我都会创建一个新的工作空间。虽然这在 GitLab 上尚未实现(还没有?),但在使用 Github 时,如果你有一个不包含任何项目部分的 devfile.yaml,加载 Github 项目分支的 URL 将会加载带有正确分支的工作空间。

例如:

http://che.openshift.io/factory?url=https://github.com/sunix/quickperf-examples/tree/didact

将会加载该 didact 分支中的 devfile.yaml,并最终在同一分支中克隆项目。

从仪表板加载 devfile 也是同样的情况。

虽然我们还没有 GitLab 的等价功能,但实现它应该相当简单。欢迎任何贡献,我们将乐意提供帮助。

英文:

I don't know how you work with Che. But AFAIC, I create one workspace everytime i work on a new task/issue. It is not implemented for gitlab (yet?) but with Github, if you have a devfile.yaml without any project section, loading the github project-branch url would load the workspace with the right branch.
For instance:

http://che.openshift.io/factory?url=https://github.com/sunix/quickperf-examples/tree/didact

will load the devfile.yaml in that didact branch and finally clone the project in the same branch.

Same if you load the devfile from the dashboard.

We don't have the gitlab equivalent but it should be quite easy to implement it. Any contribution are welcome and we would be happy to help you.

huangapple
  • 本文由 发表于 2020年9月26日 00:43:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/64068217.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定