Feature request : allow to reset local branch when double clicking on remote branch
Suppose we have a "origin/branch" branch in the repository, and a local branch named "branch", tracking the remote branch
When double clicking on the "origin/branch" commit:
- When local and remote branches are referencing the same commit, nothing happens
- When local and remote branches are not referencing the same commit, when double clicking on the remote branch, SourceGit opens the "Create Local Branch". 99% of the time, what I want to do is to reset the local branch on the remote branch.
- It would be nice to add this option : when double clicking on the remote branch, if one local branch tracks the remote branch, then open the "Reset branch to revision" and on select, checkout the local branch and reset to the remote branch.
Currently, the way SourceGit handles double-clicking on a remote branch is as follows:
- If the local branch tracked that remote branch is exactly the same as the remote one, it checks whether the local branch is already the current branch. If it is, nothing happens; if not, the
Checkoutpanel pops up. - If the local branch has no ahead commits but behind the remote branch, the
Checkout & Fast-Forwardpanel pops up. - If the local branch has ahead commits, the
Create Branchpanel pops up to prevent some locally commits (not pushed to remote) from being lost.
If the panel that pops up is Create Branch instead of Checkout & Fast-Forward or Checkout, you should decide for yourself which merge method to use: reset/rebase/merge
TIPS:
- You can also select the target revision by click remote branch in
REMOTESbranch tree, then use context menu of selected commit to do this. - You can also reset a non-current local branch to selected commit in
HISTORYwithout checkout it. - You can also update a non-current local branch to its tracking remote without checkout via
Fetch intofeature when this local branch has no ahead commits
For double-clicking on branch tree, there's no plan to do this.
I'm talking about this case:
If the panel that pops up is Create Branch instead of Checkout & Fast-Forward or Checkout, you should decide for yourself which merge method to use: reset/rebase/merge
In this case if you do not want to change the double click behavior, would it be possible to add an entry to the context menu : In this case it would be main >
- Reset main to Here
- Rebase main to Here
In my case, the local branch if often "lost" somewhere because it checked it out a long time ago and I juste want to reset or rebase the the origin.
- You can only do merge/rebase on a local branch after it is checkout (to resolve conflicts). In another word,
Rebase/Mergethese operations are only applicable to the current branch. You must checkout it first then do rebase or reset. - I've show you another way to do this in the second tip: select a commit in
HISTORYcommit list, then open the context menu of local branch (non-current), you will see a context menu entryReset <branch_name> to <revision_sha>. This option will reset the target branch to the selected revision without checkout it.
You can also reset a branch without checkout it through Create Local Branch popup.
You can only do merge/rebase on a local branch after it is checkout (to resolve conflicts). In another word, Rebase/Merge these operations are only applicable to the current branch. You must checkout it first then do rebase or reset.
This is what wastes time : in order to checkout, you need to find it in the tree (or search using filter). This is not straightforward
I've show you another way to do this in the second tip: select a commit in HISTORY commit list, then open the context menu of local branch (non-current), you will see a context menu entry Reset <branch_name> to <revision_sha>. This option will reset the target branch to the selected revision without checkout it.
Not sure to understand, what I want is to have an action on the remote branch
You can also reset a branch without checkout it through Create Local Branch popup.
This is close from what I want. It would be great is SourceGit could detect dans propose local branch tracking the remote
This is what wastes time : in order to checkout, you need to find it in the tree (or search using filter). This is not straightforward
But it is needed by git merge or git rebase command. Imagine the following scenario: during the process of merge or rebase, conflicts occur. If you don't checkout the target branch, where are these files placed? You surely can't overwrite the content of the current branch...
You can git merge only available for current branch, and git rebase will make sure the target brach is checkout by run git switch <branch> if it is not checkout
Of course, SourceGit would first need to checkout the local branch, then reset/rebase.