Search code examples
javagiteclipsegitlabeclipse-che

How to switch git branch in Eclipse Che


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!


Solution

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