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

Re: Git Commit Notes (fetching/pushing)

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 7, 2023, 16:14 UTC
Message-ID
<xmqq4jlaj0dp.fsf@gitster.g>
In-Reply-To
<2301E39E-B70D-485B-AFA8-F8DA64B366A2@alchemists.io>
Brooke Kuhlmann <brooke@alchemists.io> writes:
Show 9 quoted lines
> I ended up using the following configuration in order to
> explicitly fetch/push branches, notes, and tags:
>
> [remote "origin"]
> 	url = https://github.com/bkuhlmann/test
> 	fetch = +refs/heads/*:refs/remotes/origin/*
> 	fetch = +refs/notes/*:refs/notes/*
> 	fetch = +refs/tags/*:refs/tags/*
> 	push = +refs/heads/*:refs/remotes/origin/*

This will push your local branches (e.g. refs/heads/xyzzy) to their remote-tracking branches (e.g. refs/remotes/origin/xyzzy) of the same name. Is that what you meant? It is unclear what kind of use you have your remote repository for, and in some use cases, it is perfectly valid if a push from here is used as a substitute for a fetch from there to arrange the push from here like how you have above, to push into refs/remotes/origin/* of a remote repository with a working tree.

But often, a remote is used as a publishing point (i.e. everybody pulls from and only you push into it) or as a central meeting place (i.e. everybody pulls from and pushes into it), and in these cases, a push refspec would look more like

	push = refs/heads/*:refs/heads/*

This is especially true when the remote is a bare repository, or hosted at a hosting site you or nobody has access to its working tree.

Note the lack of leading '+'; that is absolutely essential if you are pushing into a central meeting place because you want to avoid force pushing that will clobber others' work, and it is also a great discipline even if you are pushing into your publishing point because those in your downstream will be disrupted if you rewind your history.

Previous: Brooke KuhlmannNext: Brooke Kuhlmann
Message 6 of 7 in “Git Commit Notes (fetching/pushing)”
  1. Brooke KuhlmannAug 6, 2023
  2. Taylor BlauAug 6, 2023
  3. Brooke KuhlmannAug 6, 2023
  4. Junio C HamanoAug 7, 2023
  5. Brooke KuhlmannAug 7, 2023
  6. Junio C HamanoAug 7, 2023
  7. Brooke KuhlmannAug 7, 2023

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.