Translations
Info
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

Explanation

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>@review.typo3.org/<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>@review.typo3.org:29418/<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 review.typo3.org. You'd end up with git push ssh://review.typo3.org/<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://git.typo3.org/XYZ/ABZ' then just use a different URL 'ssh://<username>@review.typo3.org:29418/XYZ/ABZ' for the push operation. You need to set this config either local or global:

shell script:
# global
git config --global url."ssh://<username>@review.typo3.org:29418".pushInsteadOf git://git.typo3.org
# local
git config url."ssh://<username>@review.typo3.org:29418".pushInsteadOf git://git.typo3.org

Warning

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.

HEAD:refs/for/<targetbranch>

ToDo alias(?)

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