fork-dev / Tracker

Bug and issue tracker for Fork for Mac
506 stars 12 forks source link

Unable to checkout to local branch #2207

Open matheusamazonas opened 1 week ago

matheusamazonas commented 1 week ago

I am facing this same issue on two different repositories. I have a branch named develop and I am not aware to switch to it. I've tried double clicking on the branch name and also right clicking and selecting "Checkout develop". Nothing happens. The history doesn't contain a checkout develop attempt. There is no progress bar or any popup displayed.

I can check every other branch out, but not develop. I have a hunch that this might be related to worktrees because the only repositories that I can reproduce this issue are the ones that I have worktree set up, and the worktree I'm currently using was based on the develop branch. Here's a list of all the branches I currently have:

Screenshot 2024-09-23 at 11 42 55

If I try to checkout another branch that has a worktree setup (like master), a new Fork tab is opened in that workspace.

Fork versions I could reproduce the issue:

macOS 14.6.1.

matheusamazonas commented 1 week ago

I was not able to reproduce this issue on Fork:

But I was able to reproduce it on:

So it seems that 2.45.X broke it for me.

DanPristupov commented 1 week ago

Do you mean worktrees (git feature) or worspaces (the ability to manage tabs in Fork)?

Starting 2.45, if a branch is tied to a worktree, instead of checkout Fork opens corresponding worktree repo in a new tab.

matheusamazonas commented 1 week ago

Sorry, I meant worktrees.

I understand the 2.45 behavior, but that does not happen. Nothing happens if I try the check the develop branch out. A new tab is opened if I try to check the master branch out, but not develop.

I also did not expect a new tab to be opened when I try to check develop out, because that's the branch that my current worktree is based off. I just want to check the branch out.

DanPristupov commented 1 week ago

Thank you for the details. Let me have a look.

DanPristupov commented 1 week ago

Can you open 'Worktrees' section on the sidebar and check which worktree is on the develop branch? Can you open this worktree?

matheusamazonas commented 1 week ago

On Fork 2.46.2, this is what my sidebar looks like:

Screenshot 2024-09-23 at 13 09 58
matheusamazonas commented 1 week ago

It's also worth noting that before jumping to the feature/blokki_review branch, my corpus-vr-headset-develop worktree was on the develop branch. I just can't switch back to it.

DanPristupov commented 1 week ago

Check tooltips over the worktree items. Does any of them track 'develop'?

matheusamazonas commented 1 week ago

No.

Screenshot 2024-09-23 at 14 49 25
DanPristupov commented 1 week ago

Can you send me an email (support@fork.dev) and I'll send you a debug build with verbose logging, please?

matheusamazonas commented 1 week ago

Any updates on this? Were you able to reproduce the bug?

DanPristupov commented 1 week ago

Well, as you and I found out, the parent repo Development is on the develop branch, even though it's a bare repo.

I didn't check if Fork can recognize whether parent repo is bare yet, but you can fix the problem by changing the active branch in the Development repo.

matheusamazonas commented 1 week ago

If I understood correctly, bare repos can't be checked out and they are never in a branch. The following commands don't work in bare repos:

work@Matheus-MBP corpus-vr-headset % git status
fatal: this operation must be run in a work tree
work@Matheus-MBP corpus-vr-headset % git checkout master
fatal: this operation must be run in a work tree
matheusamazonas commented 1 week ago

And just to confirm my folder structure: the Development folder isn't a git repository:

work@Matheus-MBP ~ % cd ~/Development 
work@Matheus-MBP Development % git status
fatal: not a git repository (or any of the parent directories): .git

The Development/corpus-vr-headset is a bare git repository:

work@Matheus-MBP Development % cd ~/Development/corpus-vr-headset 
work@Matheus-MBP corpus-vr-headset % git worktree list
/Users/work/Development/corpus-vr-headset                            (bare)
/Users/work/Development/corpus-vr-headset/corpus-vr-headset-develop  f483f191f [develop]
/Users/work/Development/corpus-vr-headset/corpus-vr-headset-master   51cff94d3 [master]
work@Matheus-MBP corpus-vr-headset % git status
fatal: this operation must be run in a work tree
DanPristupov commented 1 week ago

bare repos can't be checked out and they are never in a branch.

Bare repos have active branch.

Here is how to change it: https://stackoverflow.com/questions/3301956/git-correct-way-to-change-active-branch-in-a-bare-repository

if you want the default branch to be something other than master, you need to do this: git symbolic-ref HEAD refs/heads/mybranch

matheusamazonas commented 1 week ago

Bare repos have active branch.

Interesting. TIL.

Anyway, that fixed it. Thank you!

I will close this issue because my problem was solved, but it would be nice if Fork could somehow identify it in the future. Otherwise, it seems like the app just isn't responding to my commands and that is quite frustrating. I know that worktrees are not that common, and bare ones even less, but I can imagine that I won't be the first one to run into this issue.

DanPristupov commented 1 week ago

I'll keep it open if you don't mind. We need to check if this can be fixed.

it would be nice if Fork could somehow identify it in the future

👍