Skip to content
Snippets Groups Projects
Commit 8437a52b authored by Laurent Heirendt's avatar Laurent Heirendt :airplane:
Browse files

Further changes to slides, essentially branches

parent e1f2321c
No related branches found
No related tags found
No related merge requests found
## Branches ## Branches
Expérimentez en toute sécurité Branch-off within the same repository in order to stay safe!
The master branch:
<img src="img/branch-0-master.png" class="as-is" /> <img src="img/branch-0-master.png" class="as-is" />
## Une branche = Une fonctionnalité ## One branch per feature
Assume that you want to work on a function for a matrix-vector operation.
```shell ```shell
$ git checkout -b noel $ git checkout -b matrix_vect_mult_myName
``` ```
The `-b` flag creates the branch.
<img src="img/branch-1-checkout-b.png" class="as-is" /> <img src="img/branch-1-checkout-b.png" class="as-is" />
## Navigation ## Switch between branches
Lister les branches In your terminal, you may see the name of the branch you are on.
```shell
List available branches of the repository
```sh
$ git branch $ git branch
``` ```
Se positionner dans une branche <div class="fragment">
```shell <br>
Checkout another branch
```sh
$ git checkout <branch_name> $ git checkout <branch_name>
``` ```
<div class="fragment">
```shell <br>
$ git commit You can switch back to master with
```sh
$ git checkout master
``` ```
<img src="img/branch-2-commit.png" class="as-is" />
<div class="fragment">
<br>
You can use the 5 essential commands as before.
## Fusion Only difference: you are on your own branch.
### En anglais, _merge_
```shell ## Merge a branch
$ git checkout master
$ git diff master..noel
$ git merge noel
```
<img src="img/branch-3-merge.png" class="as-is" />
If you want your feature on the `develop` or `master` branches, merge your branch with the
`develop` or `master` or branch:
## Nettoyage <br>
**submit a MR or a PR** via the Github/Gitlab interface.
<!-- PICTURES HERE //-->
```shell <div class="fragment">
$ git branch -d noel <br>
**ADVANCED**: You can see the differences between branches
```sh
$ git diff master..matrix_vect_mult_myName
``` ```
<img src="img/branch-4-br-d.png" class="as-is" />
<br>
You can delete the branch via the interface.
...@@ -32,30 +32,6 @@ $ git pull origin master # Récupérer le travail ...@@ -32,30 +32,6 @@ $ git pull origin master # Récupérer le travail
Terminologie de l'application GitHub Terminologie de l'application GitHub
## Avoid conflicts ## Pull/Merge Requests
Good practice: How to submit a Pull or Merge Request (PR or MR)
<large>**PULL**</large> before you **push**!
Do **not** combine `git` commands
```sh
$ git commit -am "myMessage" # do not do this
```
Verify to have the right remote set on your fork
```sh
$ git remote -v
```
Keep your fork up-to-date
```sh
$ git fetch upstream
$ git merge upstream/master
$ git push origin master # do not do git push (!)
```
## Pull Requests
How to submit a Pull Request (PR)
...@@ -11,9 +11,3 @@ Positive point: GitHub and GitLab are (almost) the same. ...@@ -11,9 +11,3 @@ Positive point: GitHub and GitLab are (almost) the same.
## GitLab ## GitLab
## Good practices
Always `clone` a repository, do not download the `.zip` file.
...@@ -2,9 +2,12 @@ ...@@ -2,9 +2,12 @@
1. `clone` a repository, do not download the `.zip` file. 1. `clone` a repository, do not download the `.zip` file.
2. `pull` before `push` 2. `pull` before `push`
3. Work on your own branch (in your own fork) 3. Work on your **own** branch (in your own fork)
4. Do not `push` to `master` 4. Do **not** `push` to `master` or `develop` (submit PR)
5. Do not `push` to `develop` 5. Do **not** combine `git` commands
```sh
$ git commit -am "myMessage" # do not do this
```
6. Stage only 1 file at once using 6. Stage only 1 file at once using
```sh ```sh
$ git add myFile.txt $ git add myFile.txt
...@@ -12,6 +15,12 @@ $ git add myFile.txt ...@@ -12,6 +15,12 @@ $ git add myFile.txt
7. Commit only a few files at once 7. Commit only a few files at once
8. Submit a PR instead of pushing directly 8. Submit a PR instead of pushing directly
9. Always sync your fork before starting to work 9. Always sync your fork before starting to work
```sh
$ git remote -v # verify to have the right remote set
$ git fetch upstream
$ git merge upstream/master
$ git push origin master # do not do git push (!)
```
10. `Push` often - avoid conflicts 10. `Push` often - avoid conflicts
<br><br> <br><br>
......
...@@ -62,9 +62,7 @@ $ git config -l ...@@ -62,9 +62,7 @@ $ git config -l
This should list the configuration with `user.name` and `user.email`. This should list the configuration with `user.name` and `user.email`.
## I need to get ## I need `The COBRAToolbox` - How?
<br>
##`The COBRAToolbox` - How?
Simply `clone` the repository (i.e., retrieve a copy) Simply `clone` the repository (i.e., retrieve a copy)
```sh ```sh
...@@ -79,7 +77,7 @@ Any other rudimentary method such as ...@@ -79,7 +77,7 @@ Any other rudimentary method such as
shall **be avoided**! shall **be avoided**!
## How do I get any other repository? ## How do I `clone` any other repository?
You can clone any other repository with: You can clone any other repository with:
```sh ```sh
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment