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

git-push: creating branch on remote, refspec format

From
LKLasse Kliemann <lasse-gmane-git-2009@mail.plastictree.net>
Date
Feb 26, 2009, 12:00 UTC
Message-ID
<go609m$3dj$2@ger.gmane.org>
http://www.kernel.org/pub/software/scm/git/docs/git-push.html reads:
| git push origin master:refs/heads/experimental
| 
|   Create the branch experimental in the origin repository by copying the 
|   current master branch. This form is only needed to create a new branch or 
|   tag in the remote repository when the local name and the remote name are 
|   different; otherwise, the ref name on its own will work.

It appears to me that the ref name on its own will also work to create a new branch, at least with local repositories:

$ (mkdir a && cd a && git init)
Initialized empty Git repository in /tmp/a/.git/
$ mkdir b && cd b && git init
Initialized empty Git repository in /tmp/b/.git/
$ pwd
/tmp/b
$ touch x && git add x && git commit 
[master (root-commit)]: created 87a90f5: "NA"
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 x
Now the push from '/tmp/b' to '/tmp/a':
$ git push /tmp/a master:foo
Counting objects: 3, done.
Writing objects: 100% (3/3), 209 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To /tmp/a
 * [new branch]      master -> foo
Am I missing something?
Next: Michael J Gruber
Message 1 of 3 in “git-push: creating branch on remote, refspec format”
  1. Lasse KliemannFeb 26, 2009
  2. Michael J GruberFeb 26, 2009
  3. Jeff KingFeb 26, 2009

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.