Commit 2eb1c6b6 authored by Laurent Heirendt's avatar Laurent Heirendt
Browse files

Final changes to slides

parent d6b8fdf0
## Best practices
* `clone` a repository, do not download the `.zip` file.
* `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**
* 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
```bash
$ git commit -am "myMessage" # do not do this
```
* Stage only 1 file at once using
```bash
$ git add myFile.txt
......@@ -16,13 +24,15 @@
* 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
$ 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 (!)
```
* `Push` often - avoid conflicts
<br><br>
......
......@@ -53,7 +53,7 @@ Uncomment the line
```
<br>
Save and rename the file by adding your name
Save and rename the file by <font color="red">adding your name</font>
```bash
$ mv firstCommit/addTwoNumbers.m firstCommit/addTwoNumbers_myName.m
```
......@@ -110,13 +110,18 @@ $ git push
```bash
$ 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
* Modify and rename `secondCommit/multiplyTwoNumbers.m`
* Push the file `secondCommit/multiplyTwoNumbers_myName.m`
* Don't forget to add <font color="red">`_myName`</font>
<div class="fragment">
<br>
......
......@@ -9,6 +9,9 @@ Remember:
- A **fork** 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
......
## 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.*
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`.
## 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.
......@@ -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.
<br>
That's it!
......@@ -62,13 +62,23 @@ $ git config --list
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
$ 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>
Any other rudimentary method such as
......@@ -77,17 +87,12 @@ Any other rudimentary method such as
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
$ git clone https://github.com/userName/myRepo.git myRepo
$ git clone https://github.com/opencobra/cobratoolbox.git cobratoolbox
```
<div class="fragment">
<br>
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.
<br><br>
**Do not** do it right now! Thank you.
......@@ -5,7 +5,7 @@
2. GitHub and GitLab <!--(5min)//-->
3. Installation of `git`
4. The 5 essential commands <!--(10 min)//-->
* `clone/pull` / `status` / `add` / `commit` / `push`
* `pull` / `status` / `add` / `commit` / `push`
5. Branches <!--(10 min)//-->
6. Forks <!--(10 min)//-->
7. Best practices
......
......@@ -26,12 +26,19 @@ $ ls
<div class="fragment">
<br>
Change the directory to a specific folder
Create a directory
```bash
$ cd myDirectory
$ mkdir myNewDirectory
```
<div class="fragment">
<br>
Change the directory to a specific folder
```bash
$ cd myNewDirectory
```
<br>
Change the directory 1 level and 2 levels up
```bash
......@@ -42,18 +49,11 @@ $ cd ../..
# 2 levels up
```
<br>
Create a directory
```bash
$ mkdir myNewDirectory
```
<div class="fragment">
<br>
Move a file or a directory
```bash
$ mv myFile.m myDirectory/.
$ mv myFile.m myNewDirectory/.
```
<div class="fragment">
......@@ -61,4 +61,5 @@ $ mv myFile.m myDirectory/.
Rename a file or a directory
```bash
$ mv myFile.m myNewFile.m
$ mv myNewDirectory myDirectory
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment