git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How to git push mirror local refs only?

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 10, 2017, 01:53 UTC
Message-ID
<xmqqpoec4nib.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAHd499BBNsai4SScOe6kADsgbGRLyGnDKyUcm8LZL-w8c9Webw@mail.gmail.com>
Robert Dailey <rcdailey.lists@gmail.com> writes:
Show 16 quoted lines
> So I want to update my remote fork with all my local branches.
> Normally I'd do this:
>
> $ git push --mirror fork
>
> However this will also push everything under `refs/remotes` which I do
> not want. And it fails if I specify a refspec parameter with --mirror.
>
> Is there a way to achieve this through one or more git commands? Note
> I'm doing this on a non-bare clone and have to keep it that way since
> I'm pushing branches I actively work on.
>
> An intrinsic benefit of what I'm trying to do is that the mirror
> command will also batch delete branches on the remote that do not
> exist locally, which is behavior I want since I do not need them
> anymore.
Something along this line in your .git/config:
	[remote "fork"]
		url = ...
		push = refs/heads/*:refs/heads/*
and then
	$ git push --prune --follow-tags fork
Previous: Robert DaileyNext: Robert Dailey
Message 2 of 4 in “How to git push mirror local refs only?”
  1. Robert DaileyJun 9, 2017
  2. Junio C HamanoJun 10, 2017
  3. Robert DaileyJun 19, 2017
  4. Junio C HamanoJun 19, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.