diff --git a/slides/best_practices.md b/slides/best_practices.md index bafee3744301cfe7ccc85b7288adc50c006581b1..b139f187935c35c0d2890d425a9617e01b79dbb3 100644 --- a/slides/best_practices.md +++ b/slides/best_practices.md @@ -4,11 +4,11 @@ * 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/MR** -* Get your code **reviewed** by your peers (submit a PR!) +* Get your code **reviewed** by your peers (submit a PR/MR!) -* Submit a PR **often**! +* Submit a PR/MR **often**! * `clone` a repository, do not download the `.zip` file. diff --git a/slides/branches.md b/slides/branches.md index b00b94f266f617208f63b83987ac1ba564f9ae4d..bbfddb58455f71c5bb2044d8f6ce52b772aaf6ad 100644 --- a/slides/branches.md +++ b/slides/branches.md @@ -1,114 +1,94 @@ -## Branches +## Development scheme -Branch-off within the same repository in order to stay safe! +<br> +Generally, in a repository, there are guidelines for contributing. -<br><br>The master branch -<img src="img/branch-master.png" class="branch-master" /> +<div class="fragment"> +<br> +A common development scheme is dual with a: -## One branch per feature +- **development** version of the code on `develop` +- **stable** version of the code on `master` -Assume that you want to work on a function for a matrix-vector operation. -```bash -$ git checkout -b matrix_vect_mult_myName -# creates the branch locally -``` -The `-b` flag creates the branch. +<br> +A **version** of the code is referred to as a **branch**. -<img src="img/branch-create.png" class="branch-create" /> +<div class="fragment"> +<br><br> +(Live Demo) -Push the branch to the remote repository -```bash -$ git push -``` +<br> +<font color="red">In the practice repository, the development branch is called `develop`!</font> -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 +<div class="fragment"> +<br> + Use this dual development scheme for your own repositories! - git push --set-upstream origin matrix_vect_mult_myName -``` +## Branches + +A **version** of the code (i.e., a **branch**) is made up of a sequence of code changes. + +<div class="fragment"> <br> -Follow the advice and do -```bash -$ git push --set-upstream origin matrix_vect_mult_myName -``` +These individual code changes are called **commits**. -## Switch between branches +For instance, the `master` and `develop` branches can be represented as a timeline: + +<img src="img/branch-master.png" class="branch-master" /> -In your terminal, you may see the name of the branch you are on. -List available branches of the repository +## Switch between branches + +List all branches of the repository with ```bash -$ git branch --list +$ git branch -a ``` +Exit by typing `q`. The branch with the ***** is the current branch. + <div class="fragment"> <br> Checkout another branch ```bash -$ git checkout <branch_name> +$ git checkout branchName ``` <div class="fragment"> <br> -You can switch back to the `master` branch with +You can switch to the `develop` branch with ```bash -$ git checkout master +$ git checkout develop ``` +(Live Demo) -<br> -You can use the 5 essential commands as before. -Only difference: you are on your own branch. +## Create your own version -<img src="img/branch-commit.png" class="branch-commit" /> - - -## Merge a branch - -If you want your feature on the `develop` or `master` branches, -**submit a MR or a PR** via the Github/Gitlab interface. +Assume that you want to work on a function for adding 2 numbers. +<div class="fragment"> <br> -Use the **interface** to make use of your peers to review your code! - -<img src="img/branch-merge.png" class="branch-merge" /> +<font color="red">Create a new **branch**!</font> -<br> -Once merged, you can delete the branch via the interface. +```bash +$ git checkout -b add-2-numbers +``` +The `-b` flag creates the branch. -## Github interface -<img src="https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png" alt="GitHub" style="width: 100px;"/> +Locally, you have your own version now: +<img src="img/branch-create.png" class="branch-create" /> -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** +Push your version to your fork: +```bash +$ git push origin add-2-numbers +``` - <br><br> -2. Compare the branches - - - - -<ol start="3"> - <li>Assign your peer - <br> - -  - </li> -</ol> - - -<ol start="4"> - <li>Submit the PR - - </li> -</ol> +(Live Demo) diff --git a/slides/cloneRepo.md b/slides/cloneRepo.md new file mode 100644 index 0000000000000000000000000000000000000000..99457b5638e09814cd89803782fb32b57e615bdb --- /dev/null +++ b/slides/cloneRepo.md @@ -0,0 +1,18 @@ +## How do I start working on a repository? + +You have to `clone` it first: + +```bash +$ 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. diff --git a/slides/configuration.md b/slides/configuration.md new file mode 100644 index 0000000000000000000000000000000000000000..0802b341a1f3935cf0b104af69c46e7e122a900f --- /dev/null +++ b/slides/configuration.md @@ -0,0 +1,53 @@ +## How to configure `git`? + +```bash +$ 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`. + + +## What is an SSH key? + +An SSH key is a secure access credential. + + +## Why do I need an SSH key? + +<br> +**Idea**: <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 is a file with an extension `.pub`, you already 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 +``` + +<br> +Then, add the SSH key to Github/Gitlab (see demo). + diff --git a/slides/essential_commands.md b/slides/essential_commands.md index 43bde21dbe1853767cff601bf054f8a2c11dd323..8da014a860cffd4222990bd3eb3bc1ac2f95328b 100644 --- a/slides/essential_commands.md +++ b/slides/essential_commands.md @@ -9,62 +9,44 @@ <br> or in other words (remember these!): ```bash -$ git pull +$ git pull <remote> <branch> $ git status $ git add myFile.txt # example $ git commit -m "myMessage" # example -$ git push +$ git push <remote> <branch> ``` ## Pull the latest version of an existing repository -First, browse to the cloned directory (`git clone [...]`): -```bash -$ cd practice -``` - Then, pull the latest revision: ```bash -$ git pull +$ git pull origin add-2-numbers # Already up to date ``` +<div class="fragment"> +<br> Verify its `status` with: ```bash $ git status ``` -## Be safe and create a new branch - -(more on branches in a few minutes) -<br><br><br><br><br> -```bash -$ git checkout -b matrix_vect_mult_myName -``` - - ## Modify a file -Modify and rename `addTwoNumbers.m` in the folder `firstCommit` - -<br> -Open the file `addTwoNumbers.m` in the folder `firstCommit` using the `Atom` editor (or any other editor). - -<br> -Then, rename the function by adding your name (`addTwoNumbers_myName`) +Modify and rename `addTwoNumbers.m` in the folder `src/firstCommit` as `addTwoNumbers_myName`: -<br> -Uncomment the line -```Matlab -% c = a + b +```bash +$ cd src/firstCommit +$ mv addTwoNumbers.m addTwoNumbers_myName.m ``` <br> -Save and rename the file by <font color="red">adding your name</font> -```bash -$ mv firstCommit/addTwoNumbers.m firstCommit/addTwoNumbers_myName.m +Open the file using the `Visual Studio Code` editor (or any other editor) +and correct the line +```Matlab +c = a + b; ``` diff --git a/slides/forks.md b/slides/forks.md index 9109050ed31bada378834b3e1fe4028b21234965..fd848cf70007e4f47212fdb95a4dcfa4ee94ede1 100644 --- a/slides/forks.md +++ b/slides/forks.md @@ -1,87 +1,86 @@ -## Forks -You **fork** when you want to work on a public repository or a protected repository. +## What is a `fork`? -<br><br> -Remember: +<div class="fragment"> +<img src="img/fork.jpg" class="as-is" /> +[//]: <> (http://www.cndajin.com/data/wls/246/22302193.jpg) + + +## Not really ... +<img src="img/fork-crossed.png" class="as-is" /> + + +## 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. -- A **fork** is your own **copy** of a repository. -- A **fork** can have multiple **branches**. -- A **fork** is not a **branch**, but can have multiple **branches**. +<div class="fragment"> +You have to work on your **own copy**. -<br><br> -A **fork** is only useful when you want to contribute, e.g., to The COBRAToolbox. +<div class="fragment"> +<br> +In other words, you have to work on your own <font color="red">**fork**</font>. -## Fork via interface +## How to get a fork? -Browse to the original repository and click on the button `Fork` +Browse to the original repository and click on the button `Fork`:  +(Live Demo) -## Clone your fork -Clone first -```bash -$ git clone https://git-r3lab.uni.lu/myGroup/myRepo.git forkMyRepo -``` +## Time to practice! + +(Live Demo) <br> -then, you can change to the directory -```bash -$ cd forkMyRepo -``` +Fork the practice repository: <br><br> +https://git-r3lab.uni.lu/R3school/git.practice -## Add the address of the original repository +Then, clone your fork to your home directory! -Add the `upstream` address (original/protected repository) +<div class="fragment"> +<br> ```bash -$ git remote add upstream https://git-r3lab.uni.lu/origGroup/origRepo.git +$ git clone ssh://git@git-r3lab-server.uni.lu:8022/yourUserName/ + git.practice.git practice ``` <br> -You can then check whether the remote address is set correctly +Change to the practice directory with: ```bash -$ git remote -v +$ cd practice ``` -<!-- <img src="img/remote-0-master.png" class="as-is" /> //--> -<!-- <img src="img/remote-1-remote.png" class="as-is" /> //--> -<!--- <img src="img/remote-2-push.png" class="as-is" /> //--> -## Synchronize your fork +<font color="red"> +Any other rudimentary method such as -```bash -$ git checkout master -$ git status -``` +*'I simply download the `.zip` and unzip it - works like a charm!'* -<div class="fragment"> -<br> -Fetch the changes from upstream (similar to pull) -```bash -$ git fetch upstream -``` +shall **be avoided**! +</font> <div class="fragment"> -<br> -Merge the retrieved changes -```bash -$ git merge upstream/master -``` +<br>Why? -<div class="fragment"> -<br> -Push the changes to your own fork -```bash -$ git push origin master -``` +## How to update my fork? + +As you have your own fork, it will not automatically update once the original repository is update. -## Pull/Merge Requests + You have to update it yourself! -**Good news!** +<div class="fragment"> +<br> +**More on that later!** -Same procedure as with merging a branch... diff --git a/slides/img/branch-create.png b/slides/img/branch-create.png index bc5e5476089018f4b94363b5e376a7b17c54785c..4ae4e4d42e620d49c6b5592037767805bd5b2188 100644 Binary files a/slides/img/branch-create.png and b/slides/img/branch-create.png differ diff --git a/slides/img/branch-i-state.graffle b/slides/img/branch-i-state.graffle index a346482195201ee5e59f918ac54c6336744fe6cb..1963daeff8e3b784c6806fc829b9172f05f9f3e4 100644 Binary files a/slides/img/branch-i-state.graffle and b/slides/img/branch-i-state.graffle differ diff --git a/slides/img/branch-master.png b/slides/img/branch-master.png index a30f3d76d63b0cd1353806b83e2635de5df0283e..37a8d0c3befc269d562a86e9eae23afd9b2ece15 100644 Binary files a/slides/img/branch-master.png and b/slides/img/branch-master.png differ diff --git a/slides/img/bulb.png b/slides/img/bulb.png new file mode 100644 index 0000000000000000000000000000000000000000..590f8d9270fea6be86b5e356cb07cd9232ef7056 Binary files /dev/null and b/slides/img/bulb.png differ diff --git a/slides/img/fork-crossed.png b/slides/img/fork-crossed.png new file mode 100644 index 0000000000000000000000000000000000000000..cd93216af30439024a36d2d6355d0eae28324511 Binary files /dev/null and b/slides/img/fork-crossed.png differ diff --git a/slides/img/fork.graffle/data.plist b/slides/img/fork.graffle/data.plist new file mode 100644 index 0000000000000000000000000000000000000000..b133d0e9ea14871d87e9c81142e1f828e1f0bc35 Binary files /dev/null and b/slides/img/fork.graffle/data.plist differ diff --git a/slides/img/fork.graffle/image1.tiff b/slides/img/fork.graffle/image1.tiff new file mode 100644 index 0000000000000000000000000000000000000000..98af73f494081c2102ae172be5d2df45588ee3ca Binary files /dev/null and b/slides/img/fork.graffle/image1.tiff differ diff --git a/slides/img/fork.graffle/image2.tiff b/slides/img/fork.graffle/image2.tiff new file mode 100644 index 0000000000000000000000000000000000000000..21127c00eebbf4f4bf48a076df8560c44afb57ca Binary files /dev/null and b/slides/img/fork.graffle/image2.tiff differ diff --git a/slides/img/fork.jpg b/slides/img/fork.jpg new file mode 100644 index 0000000000000000000000000000000000000000..35ef53f4225b9286280c99d2c23f1594d380d6c5 Binary files /dev/null and b/slides/img/fork.jpg differ diff --git a/slides/installation.md b/slides/installation.md index 258984f06e9917f97f858d35554ede049ebfff76..8c9cc67aecc707aef39c9dc4bf662584c512f12a 100644 --- a/slides/installation.md +++ b/slides/installation.md @@ -1,13 +1,7 @@ -## Installation +## Installation of `git` <img src="img/github_app.png" class="as-is" height="200" /> -**Linux (Ubuntu)** - -```bash -$ sudo apt-get install git-all -``` -<br> **macOS** Install *Xcode Command Line Tools* @@ -17,8 +11,15 @@ Install *Xcode Command Line Tools* Install Git Bash: <br>`https://git-scm.com/download/win` +<br> +**Linux (Ubuntu)** + +```bash +$ sudo apt-get install git-all +``` -## How to start? + +## How to get started? **Linux (Ubuntu)** and **macOS** @@ -30,84 +31,9 @@ Start the `Terminal` or `iTerm`. Start `GUI Bash`. -## How to configure `git`? - -```bash -$ git config --global user.name "Firstname Lastname" -$ git config --global user.email "first.last@uni.lu" -``` - - -## Does it work? +## Is `git` properly installed? ```bash $ git --version # git version 2.10.0 -``` - - -## 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`. - - -## How to set my SSH key? - -Check if you already have an SSH key: - -```bash -$ ls -al ~/.ssh -``` -If there is a file with an extension `.pub`, you already 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 -``` - -<br> -Then, add the SSH key to Github/Gitlab (see demo). - - -## How do I `clone` a repository? - -You can clone a repository with -```bash -$ git clone git@github.com:userName/myRepo.git myRepo -``` - -<br> -If you did not configure your SSH key, clone using HTTPS: -```bash -$ git clone https://github.com/userName/myRepo.git myRepo -``` -<br> -You may be prompted to enter your credentials. - - -## Clone the practice repository - -(Live Demo) - -<br> - -Clone the training repository! <br><br> -https://git-r3lab.uni.lu/R3.training/git.practice - -<div class="fragment"> -<br><br> -Any other rudimentary method such as - -*'I simply download the `.zip` un unzip it - works like a charm!'* - -shall **be avoided**! - +``` \ No newline at end of file diff --git a/slides/list.json b/slides/list.json index 860fa1bf8a7e3c56e4e30a067e5ef6aced39da23..bcd4a92325c24f102a968ec31b7d46a2148e9daa 100644 --- a/slides/list.json +++ b/slides/list.json @@ -29,6 +29,12 @@ "data-background": "img/whiteBG.jpg" } }, + { + "filename": "installation.md", + "attr": { + "data-background": "img/whiteBG.jpg" + } + }, { "filename": "github_gitlab.md", "attr": { @@ -36,13 +42,19 @@ } }, { - "filename": "installation.md", + "filename": "configuration.md", "attr": { "data-background": "img/whiteBG.jpg" } }, { - "filename": "essential_commands.md", + "filename": "cloneRepo.md", + "attr": { + "data-background": "img/whiteBG.jpg" + } + }, + { + "filename": "forks.md", "attr": { "data-background": "img/whiteBG.jpg" } @@ -53,6 +65,24 @@ "data-background": "img/whiteBG.jpg" } }, + { + "filename": "essential_commands.md", + "attr": { + "data-background": "img/whiteBG.jpg" + } + }, + { + "filename": "merge.md", + "attr": { + "data-background": "img/whiteBG.jpg" + } + }, + { + "filename": "syncFork.md", + "attr": { + "data-background": "img/whiteBG.jpg" + } + }, { "filename": "best_practices.md", "attr": { diff --git a/slides/merge.md b/slides/merge.md new file mode 100644 index 0000000000000000000000000000000000000000..02b0e99f68b2eb72df14f07829ec2b2106571963 --- /dev/null +++ b/slides/merge.md @@ -0,0 +1,43 @@ + +## Merge a branch + +If you want your feature 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="img/branch-merge.png" class="branch-merge" /> + +<br> +Once merged, you can delete the branch via the interface. + + +## Github interface +<img src="https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png" alt="GitHub" style="width: 100px;"/> + +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** + + +<br><br> +2. Compare the branches + + + + +<ol start="3"> + <li>Assign your peer + <br> + +  + </li> +</ol> + + +<ol start="4"> + <li>Submit the PR + + </li> +</ol> diff --git a/slides/ready.md b/slides/ready.md deleted file mode 100644 index 10bdd8c2d6487b004d59155128537a33ad3cf791..0000000000000000000000000000000000000000 --- a/slides/ready.md +++ /dev/null @@ -1,5 +0,0 @@ -## Ready to practice? - -<br>Go to https://git-r3lab.uni.lu/R3.training/git.practice - -<br>And follow the instructions in the `README` file. diff --git a/slides/syncFork.md b/slides/syncFork.md new file mode 100644 index 0000000000000000000000000000000000000000..75066c06c689d9616d7c73ec668b013c6744d8ad --- /dev/null +++ b/slides/syncFork.md @@ -0,0 +1,47 @@ +## Synchronize your fork + + 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 +``` + + 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 +$ git merge upstream/master +$ git push origin master +``` + +<div class="fragment"> +<br> +Do the same for the `develop` branch<br> +(replace `master` with `develop`). + + +## Time to practice! + +(Live Demo) \ No newline at end of file diff --git a/slides/thanks.md b/slides/thanks.md index 4f65b5d21da4dd42746de529b2f2e0103a140140..c88cfb83f47ad22d3d1351b12b82914253da7f92 100644 --- a/slides/thanks.md +++ b/slides/thanks.md @@ -1,11 +1,32 @@ -### References +### Let's refresh our memories + +<div class="fragment"> +<br> +- What is a **fork**? + +<div class="fragment"> +<br> +- What are **branches**? + +<div class="fragment"> +<br> +- Can I have **multiple branches** in my fork? + +<div class="fragment"> +<br> +- What is a good **development scheme**? + +<div class="fragment"> +<br> +- What are the **5 essential commands**? + + +### References & Cheat sheet [1]: **Git** Book: https://git-scm.com/book/en/v2 <br>[2]: GitHub training services: https://services.github.com/training/ - -### Cheat sheet -[Web](http://rogerdudler.github.io/git-guide/index.html) or [PDF](http://rogerdudler.github.io/git-guide/files/git_cheat_sheet.pdf) +<br>[3]: Cheat sheet: http://rogerdudler.github.io/git-guide diff --git a/slides/the_terminal.md b/slides/the_terminal.md index d63951188fe0e1e98328a138679be04b16b7c3a0..1c6c663fc330437ffaf76a165775a1b6849d7da4 100644 --- a/slides/the_terminal.md +++ b/slides/the_terminal.md @@ -5,7 +5,7 @@ Start the Terminal from your `/Applications` directoy. -*Pro Tip:* Install iTerm2: <br>`https://www.iterm2.com` + Install iTerm2: `https://www.iterm2.com` <br> **Windows users:** @@ -15,8 +15,8 @@ Install Git Bash: <br>`https://git-scm.com/download/win` <br> **Linux users:** -Launch default terminal. -*Pro Tip:* Install Terminator: <br>`https://launchpad.net/terminator` +Launch default terminal.<br> + Install Terminator: `https://launchpad.net/terminator`