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

Merge branch 'syarra' into 'develop'

Pass over all slides.

See merge request !14
parents 72391c00 b8e95928
No related branches found
No related tags found
2 merge requests!18merge all,!14Pass over all slides.
img/git_definition.png

31 KiB

......@@ -81,6 +81,16 @@
<section data-separator="^\n\n\n"
data-vertical="^\n\n"
data-background="../img/whiteBG.jpg" data-markdown="slides/why_use_git.md"></section>
<section data-separator="^\n\n\n"
data-vertical="^\n\n"
data-background="../img/whiteBG.jpg" data-markdown="slides/installation.md"></section>
......@@ -149,6 +159,16 @@
<section data-separator="^\n\n\n"
data-vertical="^\n\n"
data-background="../img/whiteBG.jpg" data-markdown="slides/ready.md"></section>
</div>
</div>
......
......@@ -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>
......
......@@ -2,14 +2,14 @@
Branch-off within the same repository in order to stay safe!
The master branch:
<br><br>The master branch
<img src="img/branch-master.png" class="branch-master" />
## 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
If you do that, `git` might complain
```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,8 +85,9 @@ 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).
Detailed information is on [docs.gitlab.com/ce/gitlab-basics/add-merge-request.html](https://docs.gitlab.com/ce/gitlab-basics/add-merge-request.html).
1. Click on **New merge request**
......@@ -105,8 +106,9 @@ 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/).
Detailed information is on [help.github.com/articles/creating-a-pull-request/](https://help.github.com/articles/creating-a-pull-request/).
1. Click on **New 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,15 +51,15 @@ Then, uncomment the line
<br>
Save and rename the file by adding your name
```sh
mv firstCommit/addTwoNumbers.m firstCommit/addTwoNumbers_myName.m
```bash
$ 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.
......@@ -23,6 +23,12 @@
"data-background": "../img/whiteBG.jpg"
}
},
{
"filename": "why_use_git.md",
"attr": {
"data-background": "../img/whiteBG.jpg"
}
},
{
"filename": "installation.md",
"attr": {
......@@ -64,5 +70,11 @@
"attr": {
"data-background": "../img/whiteBG.jpg"
}
},
{
"filename": "ready.md",
"attr": {
"data-background": "../img/whiteBG.jpg"
}
}
]
## Ready for a practice!!!
<br>Go to https://github.com/uni-lu/group_members
<br>And follow the `README` file.
## References
### References
[1]: **Git** Book: https://git-scm.com/book/en/v2
[1]: **Git** Book:
https://git-scm.com/book/en/v2
<br>[2]: GitHub training services: https://services.github.com/training/
## 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)
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)
## 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
```
## What is `git`?
![](img/git_definition.png)
<!-- ![](img/git_definition.png) -->
`git` is a **version control system** (VCS) for tracking changes in computer files and coordinating work on those files among multiple people [1].
Designed and implemented in 2005 by **Linus Torvalds**
<br><br><br>Designed and implemented in 2005 by **Linus Torvalds**
![](img/linus.jpg)
......
# Why use git?
* No need to fully rewrite code; reuse code and save time.
* Keep the changes you made over time
* Allow you to backtrack (if necessary) and undo those changes
* Easily add contributions of your collaborators to the main code base
note:
Other points to mention:
* git shall not be considered as a nuisance, but as a tool that should help to track and trace the code.
* git is not to track performance. Not using it shows exactly the opposite.
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