All page names need to be in English.
en da  de  fr  it  ja  km  nl  ru  zh

Push (Git)

From TYPO3Wiki
Jump to: navigation, search


A push transfers commits from a local repository to a remote repository.

For TYPO3 we have a Setup where the URL of the remote for fetch and push are different!

You fetch efficient/fast via git protocol from

and you push into

  • ssh://<username><projectpath>.git

This is rather uncommon and due to our usage of the gerrit review system. Now there are a bunch of different ways to accomplish this.

Bulletproof push

The push command needs the URL to send the push to as first param. So a very bulletproof way to push is to set the URL explicit when using the push command:

  • git push ssh://<username><projectpath>.git HEAD:refs/for/<targetbranch>

Comfortable Ways for push

Obviously the bulletproof way is not very comfortable, so you could ease this a little bit by adopting your .ssh/config and adding the <username> and <port> as defaults fro You'd end up with git push ssh://<projectpath>.git which is still not very comfortable.

git remote comes to our help, as we can manage a remote by just using a nice name and setting the URL and all the fancy stuff in .git/config. Actually, when we look into our .git/config or do a git remote we can see that origin is already there. That is why we can use git fetch origin and git push origin without explictly adding the URL but just by adding the name of the remote. git will pick the URL from the config. Our only trouble is that using different URL's for fetching andd pushing wasn't something that git was designed for from the beginning, so we just have one url for a remote.

use pushInsteadOf

But starting with git 1.6.4(?) they invented a very nice setting pushInsteadOf which basicly works like.... "whenever you push into a remote with an URL that fits 'git://' then just use a different URL 'ssh://<username>' for the push operation. You need to set this config either local or global:

# global
git config --global url."ssh://<username>".pushInsteadOf git://
# local
git config url."ssh://<username>".pushInsteadOf git://


there are some more hints/snippets floating around that involve the config pushUrl, while this works for single branches and projects we advice to not use that setup(???).

ToDo <refspec> <config.remote."name".push>

explain the second param <refspec>, which just says "which <src> to push into which <dst>", another uncommon usage. usually you would push the local branch into the same branch on the remote and not need the <refspec> param.


ToDo alias(?)

using git alias for a workaround. (for example git pmaster, git p45 for push master, push 46?)