Commit 6001317b authored by Sylvain Arreckx's avatar Sylvain Arreckx
Browse files

Pass over all slides.

parent 8cb4d9d8
......@@ -6,23 +6,23 @@
* Do **not push** to `master` or `develop`, but **submit a PR**
* Get your code **reviewed** by your peers (submit a PR!)
* Do **not** combine `git` commands
```sh
$ git commit -am "myMessage" # do not do this
```
```bash
$ git commit -am "myMessage" # do not do this
```
* Stage only 1 file at once using
```sh
$ git add myFile.txt
```
```bash
$ git add myFile.txt
```
* Commit **only a few files** at once (after multiple separate `git add` commands)
* 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 (!)
```
```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>
......
......@@ -9,7 +9,7 @@ The master branch:
## One branch per feature
Assume that you want to work on a function for a matrix-vector operation.
```sh
```bash
$ git checkout -b matrix_vect_mult_myName
# creates the branch locally
```
......@@ -18,13 +18,13 @@ The `-b` flag creates the branch.
<img src="img/branch-create.png" class="branch-create" />
Push the branch to the remote repository
```sh
```bash
$ git push
```
If you do that, `git` will complain
```sh
```bash
fatal: The current branch matrix_vect_mult_myName has no upstream branch.
To push the current branch and set the remote as upstream, use
......@@ -32,8 +32,8 @@ To push the current branch and set the remote as upstream, use
```
<br>
Follow the advice and do:
```sh
Follow the advice and do
```bash
$ git push --set-upstream origin matrix_vect_mult_myName
```
......@@ -43,21 +43,21 @@ $ git push --set-upstream origin matrix_vect_mult_myName
In your terminal, you may see the name of the branch you are on.
List available branches of the repository
```sh
```bash
$ git branch --list
```
<div class="fragment">
<br>
Checkout another branch
```sh
```bash
$ git checkout <branch_name>
```
<div class="fragment">
<br>
You can switch back to the `master` branch with
```sh
```bash
$ git checkout master
```
......@@ -85,6 +85,7 @@ Once merged, you can delete the branch via the interface.
## Gitlab interface
<img src="https://gitlab.com/gitlab-com/gitlab-artwork/raw/master/logo/logo.png" alt="GitLab" style="width: 100px;"/>
Detailed information is [docs.gitlab.com/ce/gitlab-basics/add-merge-request.html](https://docs.gitlab.com/ce/gitlab-basics/add-merge-request.html).
......@@ -105,6 +106,7 @@ Detailed information is [docs.gitlab.com/ce/gitlab-basics/add-merge-request.html
## Github interface
<img src="https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png" alt="GitHub" style="width: 100px;"/>
Detailed information is [help.github.com/articles/creating-a-pull-request/](https://help.github.com/articles/creating-a-pull-request/).
......
......@@ -8,7 +8,7 @@
<br>
or in other words (remember these!):
```shell
```bash
$ git pull
$ git status
$ git add myFile.txt # example
......@@ -20,18 +20,18 @@ $ git push
## Pull the latest version of an existing repository
First, browse to the cloned directory (`git clone [...]`):
```sh
```bash
$ cd practice
```
Then, pull the latest revision:
```sh
```bash
$ git pull
# Already up to date
```
Verify its `status` with:
```sh
```bash
$ git status
```
......@@ -51,7 +51,7 @@ Then, uncomment the line
<br>
Save and rename the file by adding your name
```sh
```bash
mv firstCommit/addTwoNumbers.m firstCommit/addTwoNumbers_myName.m
```
......@@ -59,7 +59,7 @@ mv firstCommit/addTwoNumbers.m firstCommit/addTwoNumbers_myName.m
## Add your file to the stage
First, check the repository status
```sh
```bash
$ git status
# uncommitted changes (displayed in red)
```
......@@ -67,7 +67,7 @@ $ git status
<div class="fragment">
<br>
Now, add the file (bring it on stage)
```sh
```bash
$ git add firstCommit/addTwoNumbers_myName.m
# returns the same as before, generally in green (means staged)
```
......@@ -75,7 +75,7 @@ $ git add firstCommit/addTwoNumbers_myName.m
<div class="fragment">
<br>
**ADVANCED**: see your changes in the terminal
```sh
```bash
$ git diff
```
exit with `:q`
......@@ -83,34 +83,34 @@ exit with `:q`
## Add a commit message
```shell
```bash
$ git commit -m "Uncommented line for adding 2 numbers"
$ git status
```
<br>
You can pull, even at this stage, new possible changes
```sh
```bash
$ git pull
```
## Push your file to the repository
```sh
```bash
$ git push
```
<div class="fragment">
<br>
**ADVANCED**: see the log of all the commits (and your last one) in the terminal
```sh
```bash
$ git log
```
exit with `:q`
## Do it yourself:
## Do it yourself
* Modify and rename `secondCommit/multiplyTwoNumbers.m`
* Push the file `secondCommit/multiplyTwoNumbers_myName.m`
......@@ -118,7 +118,7 @@ exit with `:q`
<div class="fragment">
<br>
Commands:
```sh
```bash
$ git pull
$ git diff # optional
$ git add secondCommit/multiplyTwoNumbers_myName.m
......
......@@ -2,6 +2,7 @@
You **fork** when you want to work on a public repository or a protected repository.
<br><br>
Remember:
- A **fork** is your own **copy** of a repository.
......@@ -11,21 +12,21 @@ Remember:
## Fork via interface
Browse to the original repository and click on the button `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)
## Clone your fork
Clone first:
```sh
Clone first
```bash
$ git clone https://git-r3lab.uni.lu/myGroup/myRepo.git forkMyRepo
```
<br>
then, you can change to the directory:
```sh
then, you can change to the directory
```bash
$ cd forkMyRepo
```
......@@ -33,13 +34,13 @@ $ cd forkMyRepo
## Add the address of the original repository
Add the `upstream` address (original/protected repository)
```sh
```bash
$ git remote add upstream https://git-r3lab.uni.lu/origGroup/origRepo.git
```
<br>
You can then check whether the remote address is set correctly:
```sh
You can then check whether the remote address is set correctly
```bash
$ git remote -v
```
<!-- <img src="img/remote-0-master.png" class="as-is" /> //-->
......@@ -49,7 +50,7 @@ $ git remote -v
## Synchronize your fork
```sh
```bash
$ git checkout master
$ git status
```
......@@ -57,21 +58,21 @@ $ git status
<div class="fragment">
<br>
Fetch the changes from upstream (similar to pull)
```sh
```bash
$ git fetch upstream
```
<div class="fragment">
<br>
Merge the retrieved changes
```sh
```bash
$ git merge upstream/master
```
<div class="fragment">
<br>
Push the changes to your own fork:
```sh
Push the changes to your own fork
```bash
$ git push origin master
```
......
## 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://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**.
......@@ -10,11 +13,13 @@ Positive point: GitHub and GitLab are (almost) the same.
## GitHub (Live Demo)
[www.github.com](www.github.com)
<br><img src="https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png" alt="GitHub" style="width: 200px;"/>
## GitLab (Live Demo)
[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;"/>
## Open an issue (Live Demo)
......@@ -4,8 +4,8 @@
**Linux (Ubuntu)**
```sh
sudo apt-get install git-all
```bash
$ sudo apt-get install git-all
```
<br>
**macOS**
......@@ -36,7 +36,7 @@ Start `GUI Bash` or `MobaXTerm`.
## How to configure `git`?
```shell
```bash
$ git config --global user.name "Firstname Lastname"
$ git config --global user.email "first.last@uni.lu"
```
......@@ -44,7 +44,7 @@ $ git config --global user.email "first.last@uni.lu"
## Does it work?
```sh
```bash
$ git --version
# git version 2.10.0
```
......@@ -54,7 +54,7 @@ $ git --version
Test whether your username and email have been registered
```sh
```bash
$ git config --list
```
......@@ -65,7 +65,7 @@ This should list the configuration with `user.name` and `user.email`.
## I need `The COBRAToolbox`?
Simply `clone` the repository (i.e., retrieve a copy)
```sh
```bash
$ git clone https://github.com/opencobra/cobratoolbox.git cobratoolbox
```
......@@ -79,15 +79,15 @@ shall **be avoided**!
## How do I generally `clone` a repository?
You can clone any other repository with:
```sh
You can clone any other repository with
```bash
$ git clone https://github.com/userName/myRepo.git myRepo
```
<div class="fragment">
<br>
Clone the training repository with:
```sh
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.
## References
### References
[1]: **Git** Book: https://git-scm.com/book/en/v2
## Acknowledgement
Laurent Heirendt
### Cheat sheet
[Web](http://rogerdudler.github.io/git-guide/index.html) or [PDF](http://rogerdudler.github.io/git-guide/files/git_cheat_sheet.pdf)
![](https://avatars0.githubusercontent.com/u/20812112?v=3&s=180)
Sylvain Arreckx
![](https://avatars1.githubusercontent.com/u/816318?v=3&s=180)
## Acknowledgement
Cheat sheet : [Web](http://rogerdudler.github.io/git-guide/index.html) or [PDF](http://rogerdudler.github.io/git-guide/files/git_cheat_sheet.pdf) prepared by [@rogerdudler](https://github.com/rogerdudler)
<table style="text-align:center; width:500px;
position:fixed;
margin-left:-250px; /* half of width */
left:50%;">
<tr>
<th>![](https://avatars0.githubusercontent.com/u/20812112?v=3&s=220)</th>
<th>![](https://avatars1.githubusercontent.com/u/816318?v=3&s=220)</th>
</tr>
<tr>
<th>Laurent Heirendt</th>
<th>Sylvain Arreckx</th>
</tr>
</table>
## The Terminal (shell)
Starting the terminal presents itself with a line where you can enter a command:
```sh
Starting the terminal presents itself with a line where you can enter a command
```bash
cesar@myComputer>
```
<div class="fragment">
<br>
Often written, for covenience, as:
```sh
Often written, for covenience, as
```bash
$
```
......@@ -20,21 +20,21 @@ in your home directory (unless otherwise configured), denoted as `~/`.
## Essential Linux commands
List the contents of a directory
```sh
```bash
$ ls
```
<div class="fragment">
<br>
Change the directory to a specific folder
```sh
```bash
$ cd myDirectory
```
<div class="fragment">
<br>
Change the directory 1 level and 2 levels up
```sh
```bash
$ cd ..
# 1 level up
......@@ -45,20 +45,20 @@ $ cd ../..
<br>
Create a directory
```sh
```bash
$ mkdir myNewDirectory
```
<div class="fragment">
<br>
Move a file or a directory
```sh
```bash
$ mv myFile.m myDirectory/.
```
<div class="fragment">
<br>
Rename a file or a directory
```sh
```bash
$ mv myFile.m myNewFile.m
```
Supports Markdown
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