checkout MR fails if remote has diverged
Checklist
-
I'm using the latest version of the extension (Run glab --version)- Extension version: Put your extension version here
-
Operating system and version: Debian 11 -
Gitlab.com or self-managed instance? both -
GitLab version (if self-managed) GitLab version here (Use the versionendpoint, like this: gitlab.my-company.com/api/v4/version) -
I have performed glab auth statusto check for authentication issues -
Run the command in debug mode (like DEBUG=true glab mr list) and attach any useful output
Summary
checkout MR fails if remote has diverged
Environment
- OS: Linux 6.1.0-0.deb11.7-amd64 x86_64
- SHELL: /bin/bash
- TERM: xterm-256color
- GLAB: glab 1.57.0 (8f5367a0)
Other:
Steps to reproduce
- clone a same repo into two folders --
folder1andfolder2 - create a new branch
branchAinfolder1and create a merge request - checkout the MR in
folder2usingglab - make changes in
folder1and make the history diverged bygit commit --amendand force push - checkout
mainbranch infolder2 - checkout the MR in
folder2usingglab
What is the current bug behavior?
If the remote has diverged from the local branches, glab mr checkout will fail.
the cause is during checkout, the cli invokes git fetch git@gitlab.com/xxx/yyy.git refs/heads/branchA:branchA trying to update the local ref to the remote.
but this happens if the remote has diverged
! [rejected] branchA -> branchA (non-fast-forward)
What is the expected correct behavior?
glab mr checkout works