jesseduffield / jesseduffield/lazygit

Respect branch.autoSetupMerge Git option

Open
#4,979 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
82.4k
Forks
3k
Avg merge
2d 18h
Merged PRs (30d)
19

Description

### Is your feature request related to a problem? Please describe.

Depending on the value of `branch.autoSetupMerge` Git can set up the upstream/merge/integration branch (`branch..merge`) differently from the push branch. This is particularly useful for triangular workflows where you pull from an "upstream" remote put push to a forked "origin" remote.

For example, with the default `autoSetupMerge` value of `true`, running `git branch myfeature origin/integration` will create a config entry of `branch.myfeature.merge = refs/heads/integration`, with `integration` being the remote tracking branch. With `autoSetupMerge = inherit` you can also just run `git branch myfeature` while on `main` and Git will set `branch.myfeature.merge = refs/heads/main`.

Unfortunately lazygit doesn't seem to respect this option, never setting the `merge` option regardless of how a branch is created. Even explicitly going to the "Remotes" tab and creating a branch from one of the remote branches doesn't set that branch as the merge branch.

### Describe the solution you'd like
It would be great if lazygit could respect the `branch.autoSetupMerge` option so that for example if it is set to `inherit` then just creating a new branch from, say, `main` will inherit its tracking branch config as expected. And when creating a branch from the "Remotes" tab is should act as if you were running `git branch ` to set that remote branch correctly as the merge branch.

In addition, although this may be a separate request, it would be great if lazygit could show the divergence for both the merge branch and the push branch if they are different. In this case showing the divergence from the "base" branch would probably be unnecessary since having a different merge branch already makes it explicit what the "base"/integration branch is, so the merge branch divergence could be shown in place of the current base branch divergence (the cyan arrow), and the push branch divergence could be shown in place of the current merge/upstream divergence (the yellow arrows). Hopefully this explanation wasn't too confusing.

### Describe alternatives you've considered
Without this support getting the desired functionality is only really possible by running Git manually.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.