Information

Author(s) Mathieu Jadin
Deadline No deadline
Submission limit No limitation

Sign in

Git: Using several branches

During groupworks, when you are several people to implement different features, you may risk to modify together parts of the same code, which will cause the application to fail if each member pushes its changes independently.

To avoid such issues, the majority of Git users use feature branches. A branch is a pointer towards a linear chain of commits in the history.

The following exemple represents the history of an application:

https://inginious.org/course/git/git_branches/git-branches.svg

The login feature is already implemented but two members of the group are now implementing the menu feature and the user profile. These two features are not finished, nor tested. Using a separated branch allows to save your work without altering the code that has already been tested (in the branch master master). Once your feature in development is ready, you can merge the feature branch with the branch master.

git branch allows you to create a local branch. To create the corresponding remote branch, you need to push it as you did it before for the branch master.


Téléchargez l'archive qui contient déjà un repository cloné dans le sous-dossier clone. Vous devez faire en sorte que les historiques locaux et distants correspondent à l'image de l'énoncé. Partez du principe que les commits Starting profile et Starting menu créent chacun un fichier vide, respectivement profile.txt et menu.txt.

Une fois que c'est fait, ré-archivez le dossier complet et uploadez-le.

Notez que le repository "distant" dans cet exercice n'est pas sur github ou dans bitbucket mais dans le dossier bare.git de l'archive.

git-branch/
├── bare.git/
|   └── [...]
└── clone/
    └── [...]

Max file size: 1.0 MiB
Allowed extensions: .zip