Search code examples
gitgithubgitlabgitlab-ci-runner

Fetch an active branch on a new machine via Gitlab GUI


enter image description here

I worked on some code on Machine A. Now, it is committed to the respective branch but it is NOT merged into master yet. Now, I want to be able to clone that branch (is the term clone the branch even correct?) on Machine B and use it there.

I know that CLI can probably take me via the route git fetch or something but I need to do this via Gitlab.com GUI.

Any pointers appreciated!


Solution

  • Simply push the Clone button: that will clone the full repository onto your local machine.

    Once cloned, you can go there and type:

    git switch yourBranch
    

    Since origin/yourBranch will have been cloned as part of the full repository history, that switch command will create automatically a local yourBranch tracking origin/yourBranch.


    Don't forget, you can even do some changes directly on the Web with the Web IDE (which can switch branches as well)

    See GitLab 15.10 (March 2023)

    Create and switch branches in the Web IDE Beta

    When you open the Web IDE Beta from a repository or merge request, the currently selected branch is used by default.

    You can create a new branch with your changes or, if you’re not on a protected branch, commit to the current branch.

    Starting with GitLab 15.10, you can now also create a new branch any time while making changes or switch branches in the Web IDE Beta.
    This way, you can boost your productivity by not having to close the Web IDE Beta to switch contexts.

    https://about.gitlab.com/images/15_10/create-web-ide-manage-branches.png -- Create and switch branches in the Web IDE Beta

    See Documentation and Issue.