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:
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
.