Prompt for setting upstream when creating a local branch off a remote branch
Currently, when creating a branch from a remote only branch - on the commit graph or from the remotes sideview - GitLens will automatically set the upstream to that remote branch in the ~\repo.git\config. However, there is no indication that this is being done.
It would be nice if GitLens prompted the user that the upstream was being set on branch creation or on push.
Notable, if you create a branch off a local and remote branch (pointing to the same commit) the upstream is not set automatically. This seems inconsistent with the above behavior.
I have observed this behavior. This has caused me confusion before, and it would have caused me trouble if I didn't have branch protection rules in place to stop me.
The menu option reads "Create Branch...", so it is more intuitive to me if the newly created branch was not set to track any remote branch. Instead, I feel like that might be the correct behavior of selecting "Rename Branch..." on a remote branch. I would also be satisfied, however, with a prompt to choose the remote tracking branch upon creation, as OP suggests.
I just realized that this behavior is in Git, under branch.autoSetupMerge. I ran this and now I get new branches with no remote tracking branch, just how I like it:
sudo git config --system branch.autoSetupMerge simple
This is quite unintuitive. I am sure in 99% of all cases when a user creates a branch (by giving it a custom name), he expects it to not track anything and then be able to publish the branch instead of it just tracking the branch it was created from.
- When using VSCode
Git: Create Branch From...command, it does exactly that (no tracking). - When using GitLens
GitLens: Git Create Branch...command, it also works correctly (no tracking). - When using GitLens
Create Branchvia context menu in theBranchesview, it does add the tracking to the source branch
So basically, the context menu Create Branch just seems to be not consistent with the rest and should imho be adjusted to behave as the commands from VSCode or even GitLens.
Edit: I guess this issue is related to https://github.com/gitkraken/vscode-gitlens/issues/1805 and https://github.com/gitkraken/vscode-gitlens/issues/1599 and a pending PR https://github.com/gitkraken/vscode-gitlens/pull/1817