0

Problem

Hi, I have a problem after rebase command on RStudio Terminal panel.

Firstly, I have 2 local branches: "main" and "mywork". When I was in one of them (I am not sure which one it was), I did something like git rebase (sorry, I don't remember the command exactly). Then the second day, when I was trying to switch to "mywork" branch from the "main" branch using git switch main, it said:

fatal: cannot switch branch while rebasing
Consider "git rebase --quit" or "git worktree add".

I suppose I am in the middle of a "rebase", but I don't know how can I solve that problem. Thank you for your help.

What I have tried 1

As I said above, I have 2 local branches: "main" and "mywork". When I was in one of them (I am not sure which one it was), I did something like git rebase (sorry, I don't remember the command exactly). Then the second day, when I was trying to switch to "mywork" branch from the "main" branch using git switch main, it said:

fatal: cannot switch branch while rebasing
Consider "git rebase --quit" or "git worktree add".

So I ran git rebase --quit accordingly, then no message popped out; then I ran git switch main again, and the same error showed up again:

fatal: cannot switch branch while rebasing
Consider "git rebase --quit" or "git worktree add".

So I tried the git worktree add, and it said:

usage: git worktree add [-f] [--detach] [--checkout] [--lock [--reason <string>]]
                        [-b <new-branch>] <path> [<commit-ish>]

    -f, --force           checkout <branch> even if already checked out in other worktree
    -b <branch>           create a new branch
    -B <branch>           create or reset a branch
    -d, --detach          detach HEAD at named commit
    --checkout            populate the new working tree
    --lock                keep the new working tree locked
    --reason <string>     reason for locking
    -q, --quiet           suppress progress reporting
    --track               set up tracking mode (see git-branch(1))
    --guess-remote        try to match the new branch name with a remote-tracking branch

I am confused about this message. So I stopped here.

What I have tried 2

I then checked the status by git status, and it said:

On branch mywork
Your branch is ahead of 'origin/mywork' by 1 commit.
  (use "git push" to publish your local commits)

You are currently rebasing.
  (all conflicts fixed: run "git rebase --continue")

nothing to commit, working tree clean

I ran git rebase --continue accordingly, but it said:

warning: could not read '.git/rebase-merge/head-name': No such file or directory

What I have tried 3

Under the "mywork" branch, I tried "git rebase --abort" and it said:

warning: could not read '.git/rebase-merge/head-name': No such file or directory

System info

I am using a mac, and I ran the command line on the Terminal panel of RStudio.

Kang
  • 31
  • 3
  • 1
    You could try `git rebase --abort` but it will reset to before the rebase – base12 Jun 06 '23 at 02:30
  • @base12masterrace Thank you. But I actually have tried that before, and it said, `warning: could not read '.git/rebase-merge/head-name': No such file or directory`. I added that to the question now. – Kang Jun 06 '23 at 04:40

0 Answers0