« Git/Branches » : différence entre les versions

Contenu supprimé Contenu ajouté
Page créée avec « {{à traduire}} {{git}} Branching is supported in most VCSs. Branching can be an expensive and time consuming operation like in centralized systems that require making a ... »
 
Aucun résumé des modifications
Ligne 1 :
{{à traduire}}
{{git}}
 
Branching is supported in most VCSs. Branching can be an expensive and time consuming operation like in centralized systems that require making a copy of the whole source tree. Branching can also be given a high priority like '''D'''VCSs do to make it faster. In git, creating branches is easy, and ''very'' fast.
 
==Branching==
Les {{w|Branche (gestion de configuration)|branches}} permettent de faire évoluer parallèlement certaines versions. Chaque soumission est donc envoyée dans une branche précise.
===View your branches===
 
Use <code>git branch</code> with nothing else to see what branches your repository has:
Le fait que Git ne nécessite pas de copier toutes ses branches sur un serveur central lui confère une plus grande rapidité.
 
===View yourVoir les branches ===
UseUtiliser <code>git branch</code> withpour nothingvisualiser else to see whatles branches yourdu repositorydépôts has:
$ git branch
* master
La branche "master" est par défaut la principale ligne de développement. Même s'il est possible de la renommer elle est généralement utilisée sous ce nom.
The branch called "master" is the default main line of development. You can rename it if you want, but it is customary to use the default. When you commit some changes, those changes are added to the branch you have checked out - in this case, master.
 
===Create newCréer des branches ===
Créons une branche "dev" :
Let's create a new branch we can use for development - call it "dev":
$ git branch dev
$ git branch
dev
* master
This only creates the new branch, it leaves your current HEAD where you remain. You can see from the * that the master branch is still what you have checked out. You can now use <code>git checkout dev</code> to switch to the new branch.
 
{{remarque|La branche crée par cette commande ne devient pas celle qui sera utilisée : ''HEAD'' ne bouge pas comme le montre l'étoile, qui représente la branche courante}}.
Alternatively, you can create a new branch and check it out all at once with
 
$ git checkout -b newbranch
Pour basculer vers la nouvelle branche :
$ git checkout dev
 
Alternativement, il aurait possible de créer et basculer vers la nouvelle branche en une seule commande :
$ git checkout -b newbranchdev
 
===Delete aEffacer une branche branch===
Utiliser le paramètre <code>-d</code> :
To delete the current branch, again use ''git-branch'', but this time send the <code>-d</code> argument.
$ git branch -d <name>dev
 
Cela peut échouer si la branche à supprimer n'a pas été fusionnée dans ''master'' :
If the branch hasn't been merged into master, then this will fail:
$ git branch -d foodev
error: The branch 'foodev' is not a strict subset of your current HEAD.
If you are sure you want to delete it, run 'git branch -D foodev'.
 
Git se prémunit donc d'effacer des changements potentiellement non vérifiés. Mais pour forcer la suppression malgré tout :
Git's complaint saves you from possibly losing your work in the branch. If you are still sure you want to delete the branch, use <code>git branch '''-D''' <name></code> instead.
$ git branch '''-D''' dev
 
=== Pushing a branch to a remote repository ===