Forked from
R3 / school / courses
1166 commits behind the upstream repository.
-
Sylvain Arreckx authoredSylvain Arreckx authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
branches.md 3.05 KiB
Branches
Branch-off within the same repository in order to stay safe!
One branch per feature
Assume that you want to work on a function for a matrix-vector operation.
$ git checkout -b matrix_vect_mult_myName
# creates the branch locally
The -b
flag creates the branch.

Push the branch to the remote repository
$ git push
If you do that, git
might complain
fatal: The current branch matrix_vect_mult_myName has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin matrix_vect_mult_myName
Follow the advice and do ```bash $ git push --set-upstream origin matrix_vect_mult_myName ```
Switch between branches
In your terminal, you may see the name of the branch you are on.
List available branches of the repository
$ git branch --list
Checkout another branch ```bash $ git checkout ```
You can switch back to the `master` branch with ```bash $ git checkout master ```
You can use the 5 essential commands as before.
Only difference: you are on your own branch.

Merge a branch
If you want your feature on the develop
or master
branches,
submit a MR or a PR via the Github/Gitlab interface.
Use the **interface** to make use of your peers to review your code!

Once merged, you can delete the branch via the interface.
Gitlab interface

Detailed information is docs.gitlab.com/ce/gitlab-basics/add-merge-request.html.
- Click on New merge request
Github interface

Detailed information is help.github.com/articles/creating-a-pull-request/.
- Click on New pull request