Tuesday, April 12, 2011

git push and other copy commands

The usual pattern of a copy command:

copy source destination

The pattern of git push command

push destination source:destination

the first destination is the destination repository - the second is the branch (and 'source' is the source branch). I must have skimmed the linked manual dozens of times over many years. There was something that just did not make sense and I imagined that I would have to read some book or something to eventually understand the magic 'ref specs'. It never dawned on me that it was that simple.

The additional difficulty is that the destination repository is usually shortened to 'origin' (because it was the origin for the clone command).


Jakub Narebski said...

You can say that "git push" is similar to

cp --target-directory=destination source1 source2 source3 ...

zby said...

But this does not have the second part of the destination at the end of the command. The : in refs looks like the colons in scp (and rsync). 'scp file1 host2:file2' looks like exactly the same pattern but has completely different meaning.