How to switch git branch in Eclipse Che

410 Views Asked by At

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:

devfile configuration in eclipse che

  • 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!

2

There are 2 best solutions below

0
On BEST ANSWER

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:

enter image description here

You will see a drop-down list with branches.

0
On

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.