# strategy: generalize push and fetch to any ref

`61ea26c`→[main](/content/gh/entireio/cli/commits/main/index.html)·

pfleidi·1mo ago·4 files·+151 added/-102 removed

pushBranchIfNeeded becomes pushRefIfNeeded; doPushBranch becomes
doPushRef; fetchAndRebaseSessionsCommon takes a ReferenceName. Branch
refs keep the has-unpushed optimization and the standard remote-tracking
destination; non-branch refs use a generic +<ref>:<ref> refspec and a
temp fetch ref. PrePush iterates refs.Push instead of pushing the v1
branch literal. The post-sync helper folds into setLocalAfterSync, which
calls AdvanceCommittedPrimary when ref is the configured Primary and a
plain SetReference otherwise.

## Sessions

94411f5e2680View transcript

[?\
Streamline Checkpoint Version Mirroring with refs.PrimaryClaude Code·1 step](/content/gh/entireio/cli/session/7d8b9a47-6f94-441b-adae-5402ded54425#timeline-94411f5e2680/index.html)

## Changes

4

- cmd/entire/cli/strategy

- Mmanual_commit_push.go+12/-7

- Mpush_common.go+82/-81

- Mpush_common_budget_unix_test.go+2/-1

- Mpush_common_test.go+55/-13

```
2 unmodified lines

3
4
5
6
6
7
8
9
10
11
11
12
13
14
14 unmodified lines

29
30
31
32
33
34
35
36
35
36
37
38
39
37
38
39
40
41
42
43
44
45

2 unmodified lines

import (
	"context"

"github.com/entireio/cli/cmd/entire/cli/paths"
	"github.com/entireio/cli/cmd/entire/cli/checkpoint"
	"github.com/entireio/cli/perf"
)

// PrePush is called by the git pre-push hook before pushing to a remote.
// It pushes the entire/checkpoints/v1 branch alongside the user's push.
// It pushes each ref in refs.Push alongside the user's push.
//
// If a checkpoint_remote is configured in settings, checkpoint branches/refs
// are pushed to the derived URL instead of the user's push remote.

```   
2 unmodified lines

```
Mcmd/entire/cli/strategy/manual_commit_push.go+12/-7

```   
22 unmodified lines

```

```   
Mcmd/entire/cli/strategy/push_common.go+82/-81

```   
10 unmodified lines
