Commit 756a3c00 authored by Laurent Heirendt's avatar Laurent Heirendt
Browse files

adding all slides adapted with the lcsb theme in pure markdown

parent 536bc446
## Development scheme
<br>
Generally, in a repository, there are guidelines for contributing.
<div class="fragment">
<br>
A common development scheme is dual with a:
- **development** version of the code on `develop`
- **stable** version of the code on `master`
<br>
A **version** of the code is referred to as a **branch**.
<div class="fragment">
<br><br>
<img src="img/icon-live-demo.png" height="100px">
<img src="slides/img/icon-live-demo.png" height="100px">
<br>
<font color="red">In the practice repository, the development branch is called `develop`!</font>
<div class="fragment">
<br>
![bulb](img/bulb.png) Use this dual development scheme for your own repositories!
![bulb](slides/img/bulb.png) Use this dual development scheme for your own repositories!
## Branches
......@@ -32,13 +31,13 @@ A **version** of the code is referred to as a **branch**.
A **version** of the code (i.e., a **branch**) is made up of a sequence of code changes.
<div class="fragment">
<br>
These individual code changes are called **commits**.
For instance, the `master` and `develop` branches can be represented as a timeline:
<img src="slides/img/branch-master.png" class="branch-master" height="500em"/>
<img src="img/branch-master.png" class="branch-master" />
## Switch between branches
......@@ -48,25 +47,26 @@ List all branches of the repository with
$ git branch -a
```
Exit by typing `q`. The branch with the ***** is the current branch.
Exit by typing `q`. The branch with the * is the current branch.
<div class="fragment">
<br>
Checkout another branch
```bash
$ git checkout branchName
```
<div class="fragment">
<br>
You can switch to the `develop` branch with
```bash
$ git checkout develop
```
<div class="fragment">
<br>
<img src="img/icon-live-demo.png" height="100px">
<img src="slides/img/icon-live-demo.png" height="100px">
## Create your own version
......@@ -74,17 +74,16 @@ $ git checkout develop
Assume that you want to work on a function for adding 2 numbers.
<div class="fragment">
<br>
<font color="red">Create a new **branch**!</font>
```bash
$ git checkout -b add-2-numbers
```
The `-b` flag creates the branch.
The `-b` flag creates the branch. Locally, you have your own version now:
<img src="slides/img/branch-create.png" class="branch-create" height="500em"/>
Locally, you have your own version now:
<img src="img/branch-create.png" class="branch-create" />
Push your version to your fork:
......@@ -92,7 +91,7 @@ Push your version to your fork:
$ git push origin add-2-numbers
```
<br>
<div class="fragment">
<br>
<img src="img/icon-live-demo.png" height="100px">
<img src="slides/img/icon-live-demo.png" height="100px">
......@@ -6,13 +6,9 @@ You have to `clone` it first:
$ git clone git@github.com:userName/myRepo.git myRepo
```
<div class="fragment">
<br>
If you did not configure your SSH key, clone using HTTPS:
```bash
$ git clone https://github.com/userName/myRepo.git myRepo
```
<br>
<div class="fragment">
You will be prompted to enter your credentials.
......@@ -5,52 +5,42 @@ $ git config --global user.name "Firstname Lastname"
$ git config --global user.email "first.last@uni.lu"
```
## Test the configuration
Test whether your username and email have been registered
```bash
$ git config --list
```
<br>
This should list the configuration with `user.name` and `user.email`.
<br>
Exit by typing `q`.
## What is an SSH key?
An SSH key is a secure access credential.
<div class="fragment">
<br>
**Principle**: <br><br>
Communicate **securely** with Github/Gitlab **without** entering the username/password.
## How do I get and set my SSH key?
<br>
Check if you already have an SSH key:
```bash
$ ls -al ~/.ssh
```
<br>
If there are 2 files named `id_rsa`, you have an SSH key.
<div class="fragment">
<br><br>
If you don’t have yet an SSH key, you have to generate one:
```bash
$ ssh-keygen -t rsa # -b 4096
```
<br>
Then, add the SSH key to Github/Gitlab.
<div class="fragment">
<img src="img/icon-live-demo.png" height="100px">
\ No newline at end of file
<img src="slides/img/icon-live-demo.png" height="100px">
\ No newline at end of file
## The 5 essential commands
<br>
**Yes**, you only need 5 commands!
<br>
`pull, status, add, commit, push`
<br>
or in other words (remember these!):
```bash
$ git pull <remote> <branch>
......@@ -17,6 +15,7 @@ $ git push <remote> <branch>
```
## Pull the latest version of an existing branch
Pull the latest revision on branch `add-2-numbers`:
......@@ -26,13 +25,14 @@ $ git pull origin add-2-numbers
```
<div class="fragment">
<br>
Verify its `status` with:
```bash
$ git status
```
## Modify a file
Modify and rename `addTwoNumbers.m` in the folder `src/firstCommit` as `addTwoNumbers_myName`:
......@@ -42,7 +42,7 @@ $ cd src/firstCommit
$ git mv addTwoNumbers_myName.m addTwoNumbers_laurent.m # replace myName
```
<br>
Open the file using the `Visual Studio Code` editor (or any other editor)
and correct the line
```Matlab
......@@ -50,6 +50,7 @@ c = a - b;
```
## Add your file to the stage
First, check the repository status
......@@ -59,7 +60,7 @@ $ git status
```
<div class="fragment">
<br>
**ADVANCED**: see your changes in the terminal
```bash
$ git diff
......@@ -67,7 +68,7 @@ $ git diff
exit with `q`
<div class="fragment">
<br>
Now, add the file (bring it on stage)
```bash
$ git add addTwoNumbers_laurent.m # replace myName
......@@ -85,6 +86,7 @@ $ git status
```
## Push your file to your fork
```bash
......@@ -92,7 +94,7 @@ $ git push origin add-2-numbers
```
<div class="fragment">
<br>
**ADVANCED**: see the log of all the commits (and your last one) in the terminal
```bash
$ git log
......@@ -100,6 +102,7 @@ $ git log
exit by typing `q`
## Do it yourself
**Exercice 1:**
......@@ -107,10 +110,11 @@ exit by typing `q`
* Edit the test in `test/suite`
<div class="fragment">
<br>
<img src="img/icon-live-demo.png" height="100px">
<img src="slides/img/icon-live-demo.png" height="100px">
<div class="fragment">
**Exercice 2:**
* Checkout a new branch named `multiply-2-numbers`
......
## What is a `fork`?
<div class="fragment">
<img src="img/fork.jpg" class="as-is" />
[//]: <> (http://www.cndajin.com/data/wls/246/22302193.jpg)
<img src="slides/img/fork.jpg" class="as-is" height="500em"/>
<!--http://www.cndajin.com/data/wls/246/22302193.jpg-->
## Not really ...
<img src="img/fork-crossed.png" class="as-is" />
<img src="slides/img/fork-crossed.png" class="as-is" height="500em"/>
## What is a `fork`?
In general, when contributing to a repository, you only have **read** access.
<div class="fragment">
In other words, you can only **pull** (unless it is your own repository or access has been granted).
<div class="fragment">
<br>
In general, you **cannot write** changes. In other words, you do not have **push** access.
<div class="fragment">
You have to work on your **own copy**.
<div class="fragment">
<br>
In other words, you have to work on your own <font color="red">**fork**</font>.
## How to get a fork?
Browse to the original repository and click on the button `Fork`:
![Fork the repo](https://help.github.com/assets/images/help/repository/fork_button.jpg)
<div class="fragment">
<img src="img/icon-live-demo.png" height="100px">
<img src="slides/img/icon-live-demo.png" height="100px">
## Time to practice!
<br>
## Time to practice!
Fork the practice repository: <br><br>
https://git-r3lab.uni.lu/R3school/git.practice
Then, clone your fork to your home directory!
<div class="fragment">
<br>
<img src="img/icon-live-demo.png" height="100px">
<img src="slides/img/icon-live-demo.png" height="100px">
<div class="fragment">
<br>
```bash
$ git clone ssh://git@git-r3lab-server.uni.lu:8022/yourUserName/
git.practice.git practice
```
<br>
Change to the practice directory with:
```bash
$ cd practice
```
## A note on shortcuts ...
<font color="red">
Any other rudimentary method such as
......@@ -73,17 +67,15 @@ Any other rudimentary method such as
shall **be avoided**!
</font>
<div class="fragment">
<br>Why?
**Why?**
## How to update my fork?
As you have your own fork, it will not automatically update once the original repository is update.
![bulb](img/bulb.png) You have to update it yourself!
![bulb](slides/img/bulb.png) You have to update it yourself!
<div class="fragment">
<br>
**More on that later!**
## GitHub and GitLab
<img src="https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png" alt="GitHub" style="width: 200px;"/>
<img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" alt="GitHub" style="width: 200px;"/>
<img src="https://gitlab.com/gitlab-com/gitlab-artwork/raw/master/logo/logo-extra-whitespace.png" alt="GitLab" style="width: 200px;"/>
GitHub and GitLab are VCS systems.
GitHub is **public**, whereas GitLab is **restricted/private**.
GitHub/Gitlab are both **publicly available**, but GitLab can be **on-premise**.
Positive point: GitHub and GitLab are (almost) the same.
## GitHub
<img src="slides/img/icon-live-demo.png" height="100px">
[https://github.com](https://github.com)
<br><img src="https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png" alt="GitHub" style="width: 200px;"/>
<div class="fragment">
<img src="img/icon-live-demo.png" height="100px">
## GitLab
[https://git-r3lab.uni.lu](https://git-r3lab.uni.lu)
<br><img src="https://gitlab.com/gitlab-com/gitlab-artwork/raw/master/logo/logo-extra-whitespace.png" alt="GitLab" style="width: 200px;"/>
<div class="fragment">
<img src="img/icon-live-demo.png" height="100px">
\ No newline at end of file
- **GitHub**: [https://github.com](https://github.com)
- Public GitLab: [https://gitlab.com](https://gitlab.com)
- LCSB specific: [https://git-r3lab.uni.lu](https://git-r3lab.uni.lu)
\ No newline at end of file
......@@ -3,14 +3,15 @@
Ideally, do this exercise on a computer on which `Matlab` or `octave` **are** installed.
<div class="fragment">
<br>
More information on how install these software are on [mathworks.com](www.mathworks.com]) or on [gnu.org/software/octave](gnu.org/software/octave)
<div class="fragment">
<br>
Don't forget to properly configure `git` with your username and email as explained in the training slides.
## Detailed instructions
- First, fork the [https://git-r3lab.uni.lu/R3school/git.practice](https://git-r3lab.uni.lu/R3school/git.practice) repository.
......@@ -26,7 +27,7 @@ Don't forget to properly configure `git` with your username and email as explain
- Before submitting the merge request, verify locally that your code is running properly.
To do so, open the MATLAB application and type `matlabroot`. This will return the path to the MATLAB application. Note or copy this path and exit MATLAB.
To do so, open the MATLAB application and type `matlabroot`. This will return the path to the MATLAB application. Note or copy this path and exit MATLAB.
NOTE: Do not copy the apostrophes, as they just denote the returned string.
Open the Terminal and execute the following command:
......@@ -36,9 +37,10 @@ Don't forget to properly configure `git` with your username and email as explain
and verify that no error is reported.
NOTE: `matlabroot`in the terminal window refers to the copied path from the previous instruction.
- Create a merge-request.
- Assign @laurent.heirendt and your merge-request will be reviewed.
<br>
That's it!
......@@ -6,11 +6,15 @@
<img src="theme/img/lcsb_bg.png">
</div>
<div style="top: 5em; left: 60%; position: absolute;">
<img src="slides/img/r3-training-logo.png" height="200px">
</div>
<div style="top: 15em; left: 60%; position: absolute;">
<h3><b>git training for absolute beginners</b></h3>
</div>
<div style="top: 24em; left: 60%; position: fixed; width: 50%;">
<div style="top: 24em; left: 61.5%; position: absolute;">
<b>Laurent Heirendt, Ph.D.</b><br>
laurent.heirendt@uni.lu<br>
......
## Installation of `git`
<img src="img/github_app.png" class="as-is" height="200" />
<img src="slides/img/github_app.png" class="as-is" height="200" />
**macOS**
Install *Xcode Command Line Tools*
<br>
**Windows**
Install Git Bash: <br>`https://git-scm.com/download/win`
<br>
**Linux (Ubuntu)**
```bash
......@@ -19,24 +19,25 @@ $ sudo apt-get install git-all
```
## How to get started?
**macOS**
Start the `Terminal` or `iTerm`.
<br>
**Windows**
Start `GUI Bash`.
<br>
**Linux (Ubuntu)**
Start the `Terminal` or `Terminator`.
## Is `git` properly installed?
**Is `git` properly installed?**
```bash
$ git --version
......
......@@ -3,15 +3,11 @@
If you want your changes to be reflected on the `develop` or `master` branches,
**submit a MR or a PR** via the Github/Gitlab interface.
<br>
Use the **interface** to make use of your peers to review your code!
<img src="slides/img/branch-merge.png" class="branch-merge" height="500em"/>
<img src="img/branch-merge.png" class="branch-merge" />
<br>
Once merged, you can delete the branch via the interface.
<div class="fragment">
<br>
<img src="img/icon-live-demo.png" height="100px">
\ No newline at end of file
<img src="slides/img/icon-live-demo.png" height="100px" >
\ No newline at end of file
## Synchronize your fork
![bulb](img/bulb.png) Remember, we have to regularly update our own copy of the code.
![bulb](slides/img/bulb.png) Remember, we have to regularly update our own copy of the code.
## Add the address of the original repository
Add the `upstream` address (original/protected repository)
```bash
$ git remote add upstream ssh://git@git-r3lab-server.uni.lu:8022/R3school/
git.practice.git
```
![bulb](img/bulb.png) Note the change in the URL.
![bulb](slides/img/bulb.png) Note the change in the URL.
<br>
You can then check whether the remote address is set correctly
```bash
$ git remote -v
```
<div class="fragment">
<br>
Fetch the changes from upstream (similar to pull)
```bash
$ git fetch upstream
```
<div class="fragment">
<br>
Merge the retrieved changes on the `master` branch:
```bash
$ git checkout master
......@@ -37,6 +35,7 @@ $ git push origin master
```
<div class="fragment">
Do the same for the `develop` branch.
<img src="img/icon-live-demo.png" height="100px">
\ No newline at end of file
<img src="slides/img/icon-live-demo.png" height="100px">
\ No newline at end of file
## Let's refresh our memories
<div class="fragment">
- What is a **fork**?
<div class="fragment">
- What are **branches**?
<div class="fragment">
- Can I have **multiple branches** in my fork?
<div class="fragment">