From 2c5aa9862146cb8b0c93df73aeef8fcdcf52fcf6 Mon Sep 17 00:00:00 2001 From: Harry Date: Fri, 27 Jun 2025 11:34:45 +0100 Subject: [PATCH 1/2] Only git fetch specific remote branch On a repo with a significant number of remote branches, fetching all remotes takes a substantial amount of time (literal minutes in our case, with thousands of remotes) This changes each `git fetch` call to fetch only the current branch name. --- mob.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mob.go b/mob.go index 267c9ef..a6df6fd 100644 --- a/mob.go +++ b/mob.go @@ -408,9 +408,9 @@ func helpRequested(parameter []string) bool { } func clean(configuration config.Configuration) { - git("fetch", configuration.RemoteName, "--prune") - currentBranch := gitCurrentBranch() + git("fetch", configuration.RemoteName, currentBranch.Name) + localBranches := gitBranches() if currentBranch.isOrphanWipBranch(configuration) { @@ -549,8 +549,9 @@ func start(configuration config.Configuration) error { return errors.New("cannot start; clean working tree required") } - git("fetch", configuration.RemoteName, "--prune") currentBranch := gitCurrentBranch() + git("fetch", configuration.RemoteName, currentBranch.Name) + currentBaseBranch, currentWipBranch := determineBranches(currentBranch, gitBranches(), configuration) if !currentWipBranch.hasRemoteBranch(configuration) && configuration.StartJoin { @@ -942,9 +943,11 @@ func done(configuration config.Configuration) { return } - git("fetch", configuration.RemoteName, "--prune") + currentBranch := gitCurrentBranch() + + git("fetch", configuration.RemoteName, currentBranch.Name) - baseBranch, wipBranch := determineBranches(gitCurrentBranch(), gitBranches(), configuration) + baseBranch, wipBranch := determineBranches(currentBranch, gitBranches(), configuration) if wipBranch.hasRemoteBranch(configuration) { if configuration.DoneSquash == config.SquashWip { From b432f1180277dfbc2c96f4b755f917a7c1fccf5c Mon Sep 17 00:00:00 2001 From: Harry Date: Fri, 27 Jun 2025 11:35:43 +0100 Subject: [PATCH 2/2] Do not do git fetch on start if doing --create for brand new branch (avoids git remote does not exist error) Following on from the previous change, we do not want to do a `git fetch mybranch` if we know the branch is not going to exist, ie in the case where we are doing `--create`. --- mob.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mob.go b/mob.go index a6df6fd..831a68c 100644 --- a/mob.go +++ b/mob.go @@ -550,8 +550,9 @@ func start(configuration config.Configuration) error { } currentBranch := gitCurrentBranch() - git("fetch", configuration.RemoteName, currentBranch.Name) - + if !configuration.StartCreate { + git("fetch", configuration.RemoteName, currentBranch.Name) + } currentBaseBranch, currentWipBranch := determineBranches(currentBranch, gitBranches(), configuration) if !currentWipBranch.hasRemoteBranch(configuration) && configuration.StartJoin {