Skip to content

Fix worktree clone to configure upstream branch tracking - #81

Merged
Boomatang merged 1 commit into
mainfrom
bug_80
Jul 18, 2026
Merged

Fix worktree clone to configure upstream branch tracking#81
Boomatang merged 1 commit into
mainfrom
bug_80

Conversation

@Boomatang

Copy link
Copy Markdown
Owner

Closes #80

Summary

When git-grab clones a repository in the default worktree (bare) mode, the resulting repository now configures per-branch upstream tracking so that git pull and git push work out of the box without manual --set-upstream-to configuration.

Three new post-clone configuration steps are added to the worktree flow:

  • Enable core.logallrefupdates so reflogs are maintained in the bare repository, matching non-bare clone behavior.
  • Set branch.autoSetupMerge to always so that future branches created from remote refs automatically configure their upstream tracking.
  • After fetching, iterate all local branches and explicitly set branch.<name>.remote and branch.<name>.merge to point at origin and refs/heads/<name> respectively. This ensures every branch present at clone time has correct tracking information.

Acceptance Criteria

The issue states that after grab git@github.com:user/repo.git, running git pull inside a worktree should work without requiring manual git branch --set-upstream-to commands.

This is addressed in two ways:

  1. Existing branches at clone time are covered by setLocalTracking, which runs after fetchOrigin and configures branch.<name>.remote and branch.<name>.merge for every local branch.
  2. Future branches are covered by setting branch.autoSetupMerge=always, so any new branch created from a remote-tracking ref will automatically inherit the correct upstream configuration.

This was all done in the hope to fix the bug reported in #80

Signed-off-by: Jim Fitzpatrick <jimfity@gmail.com>
@Boomatang
Boomatang merged commit 330c980 into main Jul 18, 2026
2 checks passed
@Boomatang
Boomatang deleted the bug_80 branch July 18, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Worktree clone does not set upstream tracking for branches

1 participant