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

Final changes to slides

parent d6b8fdf0
No related branches found
No related tags found
No related merge requests found
## Best practices ## Best practices
* `clone` a repository, do not download the `.zip` file.
* `pull` before `push` * `pull` before `push`
* Work on your **own** branch (in your own fork)
* Work on your <font color="red">own</font> branch (in your own fork), and **not** on `master` and **not** on `develop`
* Do **not push** to `master` or `develop`, but **submit a PR** * Do **not push** to `master` or `develop`, but **submit a PR**
* Get your code **reviewed** by your peers (submit a PR!) * Get your code **reviewed** by your peers (submit a PR!)
* Submit a PR **often**!
* `clone` a repository, do not download the `.zip` file.
* Do **not** combine `git` commands * Do **not** combine `git` commands
```bash ```bash
$ git commit -am "myMessage" # do not do this $ git commit -am "myMessage" # do not do this
``` ```
* Stage only 1 file at once using * Stage only 1 file at once using
```bash ```bash
$ git add myFile.txt $ git add myFile.txt
...@@ -16,13 +24,15 @@ ...@@ -16,13 +24,15 @@
* Commit **only a few files** at once (after multiple separate `git add` commands) * Commit **only a few files** at once (after multiple separate `git add` commands)
* Always **sync your fork** before starting to work
* Always **sync your fork** before starting to work on a new branch
```bash ```bash
$ git remote -v # verify to have the right remote set $ git remote -v # verify to have the right remote set
$ git fetch upstream $ git fetch upstream
$ git merge upstream/master $ git merge upstream/master
$ git push origin master # do not do git push (!) $ git push origin master # do not do git push (!)
``` ```
* `Push` often - avoid conflicts * `Push` often - avoid conflicts
<br><br> <br><br>
......
...@@ -53,7 +53,7 @@ Uncomment the line ...@@ -53,7 +53,7 @@ Uncomment the line
``` ```
<br> <br>
Save and rename the file by adding your name Save and rename the file by <font color="red">adding your name</font>
```bash ```bash
$ mv firstCommit/addTwoNumbers.m firstCommit/addTwoNumbers_myName.m $ mv firstCommit/addTwoNumbers.m firstCommit/addTwoNumbers_myName.m
``` ```
...@@ -110,13 +110,18 @@ $ git push ...@@ -110,13 +110,18 @@ $ git push
```bash ```bash
$ git log $ git log
``` ```
exit with `:q` exit by typing `q`
<div class="fragment">
<br><br>
You just pushed to `master`. This is **not a good** practice (more later!).
## Do it yourself ## Do it yourself
* Modify and rename `secondCommit/multiplyTwoNumbers.m` * Modify and rename `secondCommit/multiplyTwoNumbers.m`
* Push the file `secondCommit/multiplyTwoNumbers_myName.m` * Push the file `secondCommit/multiplyTwoNumbers_myName.m`
* Don't forget to add <font color="red">`_myName`</font>
<div class="fragment"> <div class="fragment">
<br> <br>
......
...@@ -9,6 +9,9 @@ Remember: ...@@ -9,6 +9,9 @@ Remember:
- A **fork** can have multiple **branches**. - A **fork** can have multiple **branches**.
- A **fork** is not a **branch**, but can have multiple **branches**. - A **fork** is not a **branch**, but can have multiple **branches**.
<br><br>
A **fork** is only useful when you want to contribute, e.g., to The COBRAToolbox.
## Fork via interface ## Fork via interface
......
## Homework ## Homework on GitLab
*This exercise has to be done on your lab computer on which `Matlab` **is** installed. Don't forget to properly configure `git` with your username and email, as we explained in the training slides.* *This exercise has to be done on your lab computer on which `Matlab` **is** installed. Don't forget to properly configure `git` with your username and email, as we explained in the training slides.*
During the training, you committed to the `https://git-r3lab.uni.lu/git-training/practice` repository. <br>
During the training, you committed to the
<br>
[https://git-r3lab.uni.lu/git-training/practice](https://git-r3lab.uni.lu/git-training/practice)
repository.
<br>
Your task is to create a fork of this repository, commit some code and create a merge request on `GitLab`. Your task is to create a fork of this repository, commit some code and create a merge request on `GitLab`.
## Instructions ## Homework: instructions
- First, fork the `https://git-r3lab.uni.lu/git-training/practice` repository. - First, fork the [https://git-r3lab.uni.lu/git-training/practice](https://git-r3lab.uni.lu/git-training/practice) repository.
- Create the new branch `your_name` - Create the new branch `homework_myName`.
- Implement a new function called `sqrt_myName` that computes the square root of a number. - Implement a new function (create a new file `sqrt_myName.m`) called `sqrt_myName(x)` that computes the square root of `x`.
- Copy the `test.m` file to `test_myName.m` and change the names of the functions accordingly. - Copy the `test.m` file to `test_myName.m` and change the names of the functions accordingly.
...@@ -29,4 +34,5 @@ Your task is to create a fork of this repository, commit some code and create a ...@@ -29,4 +34,5 @@ Your task is to create a fork of this repository, commit some code and create a
- Assign either Laurent (@laurent.heirendt) or Sylvain (@sylvain.arreckx) depending on your group and your merge-request will be reviewed by one of us. - Assign either Laurent (@laurent.heirendt) or Sylvain (@sylvain.arreckx) depending on your group and your merge-request will be reviewed by one of us.
<br>
That's it! That's it!
...@@ -62,13 +62,23 @@ $ git config --list ...@@ -62,13 +62,23 @@ $ git config --list
This should list the configuration with `user.name` and `user.email`. This should list the configuration with `user.name` and `user.email`.
## I need `The COBRAToolbox`? ## How do I `clone` a repository?
Simply `clone` the repository (i.e., retrieve a copy) You can clone a repository with
```bash ```bash
$ git clone https://github.com/opencobra/cobratoolbox.git cobratoolbox $ git clone https://github.com/userName/myRepo.git myRepo
``` ```
<div class="fragment">
<br>
Clone the training repository with
```bash
$ git clone https://git-r3lab.uni.lu/git-training/practice.git practice
```
<br>
You may be prompted to enter your credentials.
<div class="fragment">
<br> <br>
Any other rudimentary method such as Any other rudimentary method such as
...@@ -77,17 +87,12 @@ Any other rudimentary method such as ...@@ -77,17 +87,12 @@ Any other rudimentary method such as
shall **be avoided**! shall **be avoided**!
## How do I generally `clone` a repository? ## I need `The COBRAToolbox`?
You can clone any other repository with Simply `clone` the repository (i.e., retrieve a copy)
```bash ```bash
$ git clone https://github.com/userName/myRepo.git myRepo $ git clone https://github.com/opencobra/cobratoolbox.git cobratoolbox
``` ```
<div class="fragment"> <br><br>
<br> **Do not** do it right now! Thank you.
Clone the training repository with
```bash
$ git clone https://git-r3lab.uni.lu/git-training/practice.git practice
```
Note: You may be prompted to enter your credentials.
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
2. GitHub and GitLab <!--(5min)//--> 2. GitHub and GitLab <!--(5min)//-->
3. Installation of `git` 3. Installation of `git`
4. The 5 essential commands <!--(10 min)//--> 4. The 5 essential commands <!--(10 min)//-->
* `clone/pull` / `status` / `add` / `commit` / `push` * `pull` / `status` / `add` / `commit` / `push`
5. Branches <!--(10 min)//--> 5. Branches <!--(10 min)//-->
6. Forks <!--(10 min)//--> 6. Forks <!--(10 min)//-->
7. Best practices 7. Best practices
......
...@@ -26,12 +26,19 @@ $ ls ...@@ -26,12 +26,19 @@ $ ls
<div class="fragment"> <div class="fragment">
<br> <br>
Change the directory to a specific folder Create a directory
```bash ```bash
$ cd myDirectory $ mkdir myNewDirectory
``` ```
<div class="fragment"> <div class="fragment">
<br>
Change the directory to a specific folder
```bash
$ cd myNewDirectory
```
<br> <br>
Change the directory 1 level and 2 levels up Change the directory 1 level and 2 levels up
```bash ```bash
...@@ -42,18 +49,11 @@ $ cd ../.. ...@@ -42,18 +49,11 @@ $ cd ../..
# 2 levels up # 2 levels up
``` ```
<br>
Create a directory
```bash
$ mkdir myNewDirectory
```
<div class="fragment"> <div class="fragment">
<br> <br>
Move a file or a directory Move a file or a directory
```bash ```bash
$ mv myFile.m myDirectory/. $ mv myFile.m myNewDirectory/.
``` ```
<div class="fragment"> <div class="fragment">
...@@ -61,4 +61,5 @@ $ mv myFile.m myDirectory/. ...@@ -61,4 +61,5 @@ $ mv myFile.m myDirectory/.
Rename a file or a directory Rename a file or a directory
```bash ```bash
$ mv myFile.m myNewFile.m $ mv myFile.m myNewFile.m
$ mv myNewDirectory myDirectory
``` ```
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