Skip to content

Commit 8189114

Browse files
fix: push branches by full refname so a tag with the same name does not make them ambiguous (#2402) (#2826)
Co-authored-by: mirfalltnixein <22786734+mirfalltnixein@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 1838763 commit 8189114

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/Commands/Push.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public Push(string repo, Models.Branch local, Models.Remote remote, Models.Branc
2323
if (noVerify)
2424
builder.Append("--no-verify ");
2525

26-
builder.Append(remote.Name).Append(' ').Append(local.Name).Append(':').Append(remoteBranch.Name);
26+
builder.Append(remote.Name).Append(" refs/heads/").Append(local.Name).Append(":refs/heads/").Append(remoteBranch.Name);
2727
Args = builder.ToString();
2828
}
2929

@@ -38,7 +38,7 @@ public Push(string repo, Models.Commit revision, Models.Remote remote, Models.Br
3838
if (force)
3939
builder.Append("--force-with-lease ");
4040

41-
builder.Append(remote.Name).Append(' ').Append(revision.SHA).Append(':').Append(remoteBranch.Name);
41+
builder.Append(remote.Name).Append(' ').Append(revision.SHA).Append(":refs/heads/").Append(remoteBranch.Name);
4242
Args = builder.ToString();
4343
}
4444

‎src/ViewModels/Push.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ private void PostSelectedRemoteChanged()
296296
{
297297
target = new Models.Branch()
298298
{
299-
Name = mergeTarget,
299+
Name = mergeTarget.StartsWith("refs/heads/", StringComparison.Ordinal) ? mergeTarget.Substring(11) : mergeTarget,
300300
Remote = _selectedRemote.Name,
301301
Head = "---", // Not used by `git push` command but used by Views
302302
};

0 commit comments

Comments
 (0)