2010-04-29 14:59:14 +00:00
-----
2010-04-15 09:20:27 +00:00
isHidden: false
menupriority: 1
kind: article
created_at: 2010-03-22T10:42:27+02:00
2010-04-26 13:53:36 +00:00
title: Astuces Git
2010-05-09 12:53:46 +00:00
author_name: Yann Esposito
author_uri: yannesposito.com
2010-04-15 09:20:27 +00:00
tags:
- git
- tip
-----
2010-04-26 13:53:36 +00:00
## Cloner de github à travers un pare-feu
2010-04-15 09:20:27 +00:00
2010-04-26 13:53:36 +00:00
La façon standard:
2010-04-15 09:20:27 +00:00
< div > < code class = "zsh" >
git clone git@github.com:yogsototh/project.git
< / code > < / div >
2010-04-26 13:53:36 +00:00
En utilisant le port HTTPS :
2010-04-15 09:20:27 +00:00
< div > < code class = "zsh" >
git clone git+ssh://git@github.com:443/yogsototh/project.git
< / code > < / div >
2010-04-26 13:53:36 +00:00
## Cloner toutes les branches
2010-04-15 09:20:27 +00:00
2010-04-26 13:53:36 +00:00
`git clone` peut seulement récuper la branche `master` .
2010-04-15 09:20:27 +00:00
2010-04-26 13:53:36 +00:00
Si vous n'avez pas beaucoup de branches, vous pouvez simplement les clone le project et ensuite pour chacune d'entre elle lancer la commande suivante :
2010-04-15 09:20:27 +00:00
< div > < code class = "zsh" >
git branch --track local_branch remote_branch
< / code > < / div >
2010-04-26 13:53:36 +00:00
par exemple :
2010-04-15 09:20:27 +00:00
< div > < code class = "zsh" >
$ git clone git@github:yogsototh/example.git
$ git branch
master *
$ git branch -a
master *
remotes/origin/HEAD -> origin/master
remotes/origin/experimental
$ git branch --track experimental remotes/origin/experimental
$ git branch
master *
experimental
< / code > < / div >
2010-04-26 13:53:36 +00:00
Si vous avez beaucoup de branches il peut être utile d'utiliser *le script* /*la longue ligne de commande* suivant(e) :
2010-04-15 09:20:27 +00:00
< div > < code class = "zsh" >
# first clone your project
$ git clone git@github.com:yogsototh/project.git
# copy all branches
$ zsh
$ cd project
$ for br in $( git br -a ); do
case $br in
remotes/*) print $br ;
case ${br:t} in
master|HEAD) continue ;;
*) git branch --track ${br:t} $br ;;
esac ;;
esac
done
< / code > < / div >
2010-04-26 13:53:36 +00:00
Et toutes les branches seront récupérées en local.