Browse Source

Upgrade repo: new slides

Pierre-Yves Barriat 2 years ago
parent
commit
b06fd26f4c

+ 28 - 23
README.md

@@ -2,7 +2,7 @@
 
 ## Purpose
 
-The Git Training session started with a lesson of basics on Git and collaborative development. You can find the presentation [here](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/slides/Git_ELIC.pdf).
+The Git Training session started with a lesson of basics on Git and collaborative development. You can find the presentation [here](./slides/git_elic.html).
 
 The second part of the Git Training consists on a hands on. The objectives are to show how to use:
 
@@ -25,7 +25,7 @@ Prepare your environment for the first use of Git.
 
 For instance:
 
-```
+```bash
 git config --global user.name "My name"
 git config --global user.email "my_mail@uclouvain.be"
 git config --global color.ui auto
@@ -40,61 +40,65 @@ Clone the Git_Training repository
 
 For instance:
 
-```
+```bash
 [ ! -f ~/.ssh/id_rsa.pub ] && ssh-keygen -t rsa
 cat ~/.ssh/id_rsa.pub | xclip -sel clip
 ```
+
+```bash
 1. Go to https://gogs.elic.ucl.ac.be/user/settings/ssh, 
 2. click on the 'Add Key' button, 
 3. enter the Key Name you want, 
 4. and finally do a 'CTRL-V' in Content. 
+```
 
 And now:
-```
+
+```bash
 git clone ssh://git@www.climate.be:3022/TECLIM/Git_Training.git
 ```
 
 ### Windows or Mac
 
-[Download and Install Git](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/resources/README.md)
+[Download and Install Git](resources/README.md)
 
 Clone the Git_Training repository:
 
-```
-https://www.elic.ucl.ac.be/TECLIM/Git_Training.git
+```bash
+https://gogs.elic.ucl.ac.be/TECLIM/Git_Training.git
 ```
 
 For instance, paste the URL into TortoiseGit and it will clone the repo locally on your computer:
 
-![6.png](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/raw/master/resources/6.png)
+![6.png](resources/img/6.png)
 
 ## Tips and Tricks
 
 #### How do I add an empty directory to a Git repository ?
 
  You can't. The design of the Git staging area only accounts for files (see below for the workaround).
- 
+
 #### And if I need an empty folder anyway ?
 
 The solution to this Git empty directory problem is a simple workaround: just create a placeholder file in your empty Git directories to convince Git to put the empty directory into your Git repository. For instance:
  ```
 touch .gitkeep
  ```
- 
+
 #### Git Auto-Completion
 
-If you use the Bash shell, Git comes with a nice auto-completion script you can enable. Download it directly from the Git source code at https://github.com/git/git/blob/master/contrib/completion/git-completion.bash. Copy this file to your home directory, and add this to your ```.bashrc``` file:
+If you use the Bash shell, Git comes with a nice auto-completion script you can enable. Download it directly from the Git source code at https://github.com/git/git/blob/master/contrib/completion/git-completion.bash. Copy this file to your home directory, and add this to your `.bashrc` file:
  ```
 source ~/git-completion.bash
  ```
 
-In the same time, the following script allows you to see repository status in your prompt. Download it directly from the Git source code at https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh. Copy this file to your home directory, and add this to your ```.bashrc``` file:
- ```
+In the same time, the following script allows you to see repository status in your prompt. Download it directly from the Git source code at https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh. Copy this file to your home directory, and add this to your `.bashrc` file:
+
+ ```bash
 source ~/git-prompt.sh
 PS1=$PS1'$(__git_ps1 "\[\e[0;32m\](%s) \[\e[0m\]")'
  ```
 
-
 #### git-config
 
 Tell Git which whitespace problems it should recognize, namely any whitespace at the end of a line, as well as mixed spaces and tabs:
@@ -105,19 +109,20 @@ git config --global core.whitespace trailing-space,space-before-tab
  
 #### gitignore
 
-You don’t want to commit all your files into your repository. Things like temporary files, logs, configurations that are specific to a computer, files that are for testing only, private keys for code signing or files that can be easily regenerated all don’t belong in your repository. However, they will still show up whenever you type ```git status```, even though they are purely noise at that point.
+You don’t want to commit all your files into your repository. Things like temporary files, logs, configurations that are specific to a computer, files that are for testing only, private keys for code signing or files that can be easily regenerated all don’t belong in your repository. However, they will still show up whenever you type `git status`, even though they are purely noise at that point.
 
-For this reason you can specify what files you want Git to ignore in a special file called ```.gitignore```. Placed at the root of the repository, it contains glob patterns specifying all the files you want Git to ignore. Any file (and directory) matched by these globs won’t show up in git status, and if you try to add them via ```git add```, Git will refuse to do so (you can still add them by specifying the ```-f``` flag when adding).
+For this reason you can specify what files you want Git to ignore in a special file called `.gitignore`. Placed at the root of the repository, it contains glob patterns specifying all the files you want Git to ignore. Any file (and directory) matched by these globs won’t show up in git status, and if you try to add them via `git add`, Git will refuse to do so (you can still add them by specifying the `-f` flag when adding).
 
-For example, Rails 3 projects use the following ```.gitignore by``` default:
-```
+For example, Rails 3 projects use the following `.gitignore by` default:
+
+```bash
 .bundle
 db/*.sqlite3
 log/*.log
 tmp/
 ```
 
-This tells Git to ignore the ```.bundle``` directory, all files ending in ```.sqlite3``` in the db directory, all the logs in ```log```, and everything in the ```tmp``` directory.
+This tells Git to ignore the `.bundle` directory, all files ending in `.sqlite3` in the db directory, all the logs in `log`, and everything in the `tmp` directory.
 
 #### Using an external diff viewer
 
@@ -127,15 +132,15 @@ For this reason, Git allows you to specify external diff viewers. For instance:
 ```
 git config diff.tool vimdiff
 ```
-Then, when you want to diff, just use ```git difftool``` instead of ```git diff```. It will work as you expect.
+Then, when you want to diff, just use `git difftool` instead of `git diff`. It will work as you expect.
 
 ## Additional resources
 
-[Git cheat sheet](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/resources)
+[Git cheat sheet](./resources/)
 
-[Windows or MAC OS X](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/resources)
+[Windows or MAC OS X](./resources/)
 
-[Tricky commands](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/resources/tricky.md)
+[Tricky commands](./resources/tricky.md)
 
 [Got 15 minutes and want to learn Git?](https://try.github.io)
 

+ 12 - 10
resources/README.md

@@ -2,9 +2,9 @@
 
 ## Git cheat sheet
 
-- [git-cheat-sheet.pdf](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/resources/git-cheat-sheet.pdf)
-- [git-refcard.pdf](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/resources/git-refcard.pdf)
-- [github-git-cheat-sheet.pdf](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/resources/github-git-cheat-sheet.pdf)
+- [git-cheat-sheet.pdf](git-cheat-sheet.pdf)
+- [git-refcard.pdf](git-refcard.pdf)
+- [github-git-cheat-sheet.pdf](github-git-cheat-sheet.pdf)
 
 ## Git for Windows or Mac OS X
 
@@ -18,9 +18,11 @@ During install select the following (for any other options given choose the defa
 
 |||
 | -------- | -------- |
-| ![Git-Bash-A.png](https://webpages.uncc.edu/zwartell/Teaching/Git%20Tutorial/images/Git-Bash-A.png) | ![Git-Bash-B.png](https://webpages.uncc.edu/zwartell/Teaching/Git%20Tutorial/images/Git-Bash-B.png) |
-|![Git-Bash-C.png](https://webpages.uncc.edu/zwartell/Teaching/Git%20Tutorial/images/Git-Bash-C.png)|![Git-Bash-D.png](https://webpages.uncc.edu/zwartell/Teaching/Git%20Tutorial/images/Git-Bash-D.png)
-|![Git-Bash-E.png](https://webpages.uncc.edu/zwartell/Teaching/Git%20Tutorial/images/Git-Bash-E.png)||
+|![Git-Bash-A.png](https://zwartell.gitlab.io/Git_Tutorial_and_Coding_Standards/images/Git-Bash-A.png) |![Git-Bash-B.png](https://zwartell.gitlab.io/Git_Tutorial_and_Coding_Standards/images/Git-Bash-B.png) |
+|![Git-Bash-C.png](https://zwartell.gitlab.io/Git_Tutorial_and_Coding_Standards/images/Git-Bash-C.png) |![Git-Bash-D.png](https://zwartell.gitlab.io/Git_Tutorial_and_Coding_Standards/images/Git-Bash-D.png) |
+|![Git-Bash-E.png](https://zwartell.gitlab.io/Git_Tutorial_and_Coding_Standards/images/Git-Bash-E.png) |![Git-Bash-F.png](https://zwartell.gitlab.io/Git_Tutorial_and_Coding_Standards/images/Git-Bash-F.png) |
+|![Git-Bash-G.png](https://zwartell.gitlab.io/Git_Tutorial_and_Coding_Standards/images/Git-Bash-G.png) |![Git-Bash-H.png](https://zwartell.gitlab.io/Git_Tutorial_and_Coding_Standards/images/Git-Bash-H.png) |
+|![Git-Bash-I.png](https://zwartell.gitlab.io/Git_Tutorial_and_Coding_Standards/images/Git-Bash-I.png) |![Git-Bash-J.png](https://zwartell.gitlab.io/Git_Tutorial_and_Coding_Standards/images/Git-Bash-J.png) |
 
 > Don't forget to launch "Git Bash" to generate your ssh keys: `ssh-keygen -t rsa`
 
@@ -30,9 +32,9 @@ Setup of Git GUI’s: download and install TortoiseGit from [tortoisegit.org](ht
 
 |||
 | -------- | -------- |
-| ![Git-Bash-A.png](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/raw/master/resources/1.png) | ![Git-Bash-B.png](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/raw/master/resources/2.png) |
-|![Git-Bash-C.png](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/raw/master/resources/3.png)|![Git-Bash-D.png](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/raw/master/resources/4.png)
-|![Git-Bash-E.png](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/raw/master/resources/5.png)||
+| ![Git-Bash-A.png](img/1.png) | ![Git-Bash-B.png](img/2.png) |
+|![Git-Bash-C.png](img/3.png)|![Git-Bash-D.png](img/4.png)
+|![Git-Bash-E.png](img/5.png)||
 
 ### Mac OS X
 
@@ -46,4 +48,4 @@ Now, open a terminal and use Git as you do on Linux...
 
 Here are a few commands that you may not know yet, or that offer options you haven’t been aware of so far.
 
-[Tricky commands](https://gogs.elic.ucl.ac.be/TECLIM/Git_Training/src/master/resources/tricky.md)
+[Tricky commands](tricky.md)

+ 0 - 0
resources/1.png → resources/img/1.png


+ 0 - 0
resources/10.png → resources/img/10.png


+ 0 - 0
resources/11.png → resources/img/11.png


+ 0 - 0
resources/12.png → resources/img/12.png


+ 0 - 0
resources/13.png → resources/img/13.png


+ 0 - 0
resources/14.png → resources/img/14.png


+ 0 - 0
resources/15.png → resources/img/15.png


+ 0 - 0
resources/16.png → resources/img/16.png


+ 0 - 0
resources/17.png → resources/img/17.png


+ 0 - 0
resources/18.png → resources/img/18.png


+ 0 - 0
resources/2.png → resources/img/2.png


+ 0 - 0
resources/3.png → resources/img/3.png


+ 0 - 0
resources/4.png → resources/img/4.png


+ 0 - 0
resources/5.png → resources/img/5.png


+ 0 - 0
resources/6.png → resources/img/6.png


+ 0 - 0
resources/8.png → resources/img/8.png


+ 0 - 0
resources/9.png → resources/img/9.png


+ 13 - 13
resources/tricky.md

@@ -6,37 +6,37 @@ Here are a few commands that you may not know yet, or that offer options you hav
 
 ### git-stash
 
-```git stash``` is something that can be incredibly handy. What it does is very simple: If you run ```git stash save```, it will take all the changes you have in your working directory and the index, and save them away, leaving you with a clean working directory. Once you’ve done what you wanted to do, you can restore your changes by running ```git stash pop```.
+`git stash` is something that can be incredibly handy. What it does is very simple: If you run `git stash save` it will take all the changes you have in your working directory and the index, and save them away, leaving you with a clean working directory. Once you’ve done what you wanted to do, you can restore your changes by running `git stash pop`
 
-But it gets better: since ```git stash``` saves your changes in a commit, you can stash more than once, and you’ll get a nice list of commits with your stashed changes. ```git stash``` will also keep track of what branch you stashed your changes on, so you’ll know later on what stashed change exactly you want to restore.
+But it gets better: since `git stash` saves your changes in a commit, you can stash more than once, and you’ll get a nice list of commits with your stashed changes. `git stash` will also keep track of what branch you stashed your changes on, so you’ll know later on what stashed change exactly you want to restore.
 
-```git stash list``` will list all the stashes you’ve saved away, ```git stash apply``` will apply the topmost stashed commit onto your working directory, ```git stash pop``` will also remove the stashed commit in addition to applying it. ```git stash clear``` throws away all your stashes, and ```git stash drop``` allows you to remove a single stash.
+`git stash list` will list all the stashes you’ve saved away, `git stash apply` will apply the topmost stashed commit onto your working directory, `git stash pop` will also remove the stashed commit in addition to applying it. `git stash clear` throws away all your stashes, and `git stash drop` allows you to remove a single stash.
 
 ### git-rebase
 
-```git rebase``` can be a very tricky command, although its purpose is very simple: Given a range of commits as well as a starting point, it will port the given commits onto that starting point, preserving the commits themselves, but also allowing you to keep a linear history (that is, no merge commit).
+`git rebase` can be a very tricky command, although its purpose is very simple: Given a range of commits as well as a starting point, it will port the given commits onto that starting point, preserving the commits themselves, but also allowing you to keep a linear history (that is, no merge commit).
 
-Most of the time you’ll give it just one ref: The branch you’ll want your current branch to rebase onto. ```git rebase``` then figures out where those two branches diverged, and use that as the beginning of the commit range. If you pass it a second argument, ```git rebase``` will first switch to that branch before porting your commits.
+Most of the time you’ll give it just one ref: The branch you’ll want your current branch to rebase onto. `git rebase` then figures out where those two branches diverged, and use that as the beginning of the commit range. If you pass it a second argument, `git rebase` will first switch to that branch before porting your commits.
 
-It also has one very useful flag: ```--interactive```. If you pass this flag, Git will launch your favorite editor with a list of all the commits it is going to rebase. All commits are prefixed with ```pick``` by default, but you can either drop commits entirely (just delete their line), reorder them to your liking, or ```edit``` if you’d like to edit or amend the commit (note that this also allows you to split commits), ```reword``` if you’d just like to change the commit message, and ```squash``` or ```fixup``` if you want to squash the commit with the previous one. ```fixup``` will reuse the previous commit’s message, while ```squash``` allows you to edit the new commit’s message.
+It also has one very useful flag: `--interactive`. If you pass this flag, Git will launch your favorite editor with a list of all the commits it is going to rebase. All commits are prefixed with `pick` by default, but you can either drop commits entirely (just delete their line), reorder them to your liking, or `edit` if you’d like to edit or amend the commit (note that this also allows you to split commits), `reword` if you’d just like to change the commit message, and `squash` or `fixup` if you want to squash the commit with the previous one. `fixup` will reuse the previous commit’s message, while `squash` allows you to edit the new commit’s message.
 
-The interactive mode is very useful when you’re working on some idea you’ve had, make a commit, and later on realize that it isn’t quite working out that way. You commit a fix, but the commit it fixes is already buried in other commits, so you can’t simply amend. ```git rebase --interactive``` allows you squash those two commits together and make it look like you never made the mistake in the first place.
+The interactive mode is very useful when you’re working on some idea you’ve had, make a commit, and later on realize that it isn’t quite working out that way. You commit a fix, but the commit it fixes is already buried in other commits, so you can’t simply amend. `git rebase --interactive` allows you squash those two commits together and make it look like you never made the mistake in the first place.
 
 ### git-push
 
 This is a command that you’re probably using often already, but it gained a few more useful options in recent versions:
 
-- ```-u``` or ```--set-upstream```: When doing ```git push <repo> local-branch:remote-branch```, you can use ```-u``` to tell Git to set up ```remote-branch``` as the default upstream branch, so you’ll only need to do ```git push``` in future.
-- ```--delete```: Instead of pushing the specified refs, it will instead delete them from the remote repository.
+- `-u` or `--set-upstream`: When doing `git push <repo> local-branch:remote-branch`, you can use `-u` to tell Git to set up `remote-branch` as the default upstream branch, so you’ll only need to do `git push` in future.
+- `--delete`: Instead of pushing the specified refs, it will instead delete them from the remote repository.
 
 ### git-reflog
 
-Whenever an operation changes the tip of a branch, the Reflog mechanism records the old and new locations. ```git reflog``` allows you to access and manage this information.
+Whenever an operation changes the tip of a branch, the Reflog mechanism records the old and new locations. `git reflog` allows you to access and manage this information.
 
-This is very useful and potentially life saving after any command that (seemingly) changes the history of your repository, like ```git rebase``` or ```git filter-branch```. While these commands do indeed change commits, the old commits aren’t deleted, they are merely unreachable by normal means (This is also the reason why Git will occasionally run ```git gc``` on your repo). However, using the Reflog mechanism you can find out the SHA1’s of these commits, and restore them if you need to.
+This is very useful and potentially life saving after any command that (seemingly) changes the history of your repository, like `git rebase` or `git filter-branch`. While these commands do indeed change commits, the old commits aren’t deleted, they are merely unreachable by normal means (This is also the reason why Git will occasionally run `git gc` on your repo). However, using the Reflog mechanism you can find out the SHA1’s of these commits, and restore them if you need to.
 
-```git reflog``` lists all the recorded reflog information, and you can then specify any point in the reflog using the syntax ```head@{0}``` (where ```head``` is any kind of ref, and ```0``` to specify the very first reflog entry). For example, if you just did a rebase, but decided that you messed up somehow, you can restore your branch to its state before the rebase by using this command:
+`git reflog` lists all the recorded reflog information, and you can then specify any point in the reflog using the syntax `head@{0}` (where `head` is any kind of ref, and `0` to specify the very first reflog entry). For example, if you just did a rebase, but decided that you messed up somehow, you can restore your branch to its state before the rebase by using this command:
 
-```
+```bash
 git reset head@{1}
 ```

BIN
slides/GIT_06.png


BIN
slides/GIT_07.png


BIN
slides/Git.odp


BIN
slides/Git_ELIC.pdf


+ 0 - 0
slides/GIT_04.png → slides/assets/01.png


+ 0 - 0
slides/GIT_01.png → slides/assets/02.png


+ 0 - 0
slides/GIT_02.png → slides/assets/03.png


+ 0 - 0
slides/GIT_05.png → slides/assets/04.png


+ 0 - 0
slides/GIT_03.png → slides/assets/05.png


+ 0 - 0
slides/GIT_08.png → slides/assets/06.png


+ 0 - 0
slides/GIT_09.png → slides/assets/07.png


BIN
slides/assets/back.png


BIN
slides/assets/garde.png


BIN
slides/assets/git.png


BIN
slides/assets/git_workflow.png


+ 52 - 0
slides/assets/kroki-plugin.js

@@ -0,0 +1,52 @@
+const { deflateSync } = require('zlib')
+
+const krokiLangs = [
+  'actdiag',
+  'blockdiag',
+  'bpmn',
+  'bytefield',
+  'c4plantuml',
+  'ditaa',
+  'dot',
+  'erd',
+  'excalidraw',
+  'graphviz',
+  'mermaid',
+  'nomnoml',
+  'nwdiag',
+  'packetdiag',
+  'pikchr',
+  'plantuml',
+  'rackdiag',
+  'seqdiag',
+  'svgbob',
+  'umlet',
+  'vega',
+  'vegalite',
+  'wavedrom',
+]
+
+const entrypoint = 'https://kroki.io/'
+
+const marpKrokiPlugin = (md) => {
+  const { fence } = md.renderer.rules
+
+  md.renderer.rules.fence = (tokens, idx, options, env, self) => {
+    const info = md.utils.unescapeAll(tokens[idx].info).trim()
+
+    if (info) {
+      const [lang] = info.split(/(\s+)/g)
+
+      if (krokiLangs.includes(lang)) {
+        const data = deflateSync(tokens[idx].content).toString('base64url')
+
+        // <marp-auto-scaling> is working only with Marp Core v3
+        return `<p><marp-auto-scaling data-downscale-only><img src="${entrypoint}${lang}/svg/${data}"/></marp-auto-scaling></p>`
+      }
+    }
+
+    return fence.call(self, tokens, idx, options, env, self)
+  }
+}
+
+module.exports = marpKrokiPlugin

+ 5 - 0
slides/assets/marp.config.js

@@ -0,0 +1,5 @@
+const marpKrokiPlugin = require('./kroki-plugin')
+
+module.exports = {
+  engine: ({ marp }) => marp.use(marpKrokiPlugin)
+}

BIN
slides/assets/open_source_code.png


+ 8 - 0
slides/assets/package.json

@@ -0,0 +1,8 @@
+{
+  "license": "WTFPL",
+  "private": true,
+  "dependencies": {
+    "@marp-team/marp-cli": "^1.6.0",
+    "@marp-team/marp-core": "^3.0.2"
+  }
+}

+ 55 - 0
slides/assets/tum.css

@@ -0,0 +1,55 @@
+/* @theme tum */
+
+@import 'default';
+
+section {
+  /*background-color: #fff;
+  color: #000;
+  background-image: url('images/TUM_Logo_blau_rgb_s.svg');
+  background-repeat: no-repeat;
+  background-position: right 40px top 40px;
+  background-size: 8%;*/
+}
+
+section.lead {
+  /*background-image: url('images/TUM_Uhrenturm.png');
+  background-position: right;
+  background-size: 45%;*/
+}
+
+section h1,
+section h2 {
+  color: #1f315c;
+}
+section a {
+  color: #5fb2e6;
+}
+section footer,
+section::after {
+  color: #9cb7d4;
+}
+
+section.invert {
+  background-color: #003359;
+  color: #fff;
+  /*background-image: url('images/TUM_Logo_weiss_rgb_s.svg');*/
+}
+
+section.lead.invert {
+  /*background-image: url('images/TUM_Uhrenturm_w.png');*/
+}
+
+section.invert h1,
+section.invert footer,
+section.invert::after {
+  color: #fff;
+}
+
+section.invert a {
+  color: #e37222;
+}
+
+/* Add "Page" prefix and total page number */
+section::after {
+  content: attr(data-marpit-pagination) ' / ' attr(data-marpit-pagination-total);
+}

+ 21 - 0
slides/compile.sh

@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# PY Barriat, May 2022
+#
+# Download and install marp (MarkDown slides extension) from here:
+# https://github.com/marp-team/marp-cli/releases
+#
+# Install npm (needed for mermaid: nice extension to make diagramm)
+# npm i
+# sudo apt install npm
+#
+
+# without mermaid
+
+#marp --allow-local-files --theme tum.css git_elic.md -o git_elic.pdf
+#marp --template bespoke --bespoke.progress --allow-local-files --theme tum.css git_elic.md -o git_elic.html
+
+# with mermaid
+
+npx marp --allow-local-files --theme ./assets/tum.css -c ./assets/marp.config.js ./git_elic.md -o git_elic.pdf
+npx marp --template bespoke --bespoke.progress --allow-local-files --theme ./assets/tum.css -c ./assets/marp.config.js ./git_elic.md -o ./git_elic.html

File diff suppressed because it is too large
+ 0 - 0
slides/git_elic.html


+ 458 - 0
slides/git_elic.md

@@ -0,0 +1,458 @@
+---
+marp: true
+title: Version control with git for scientists
+author: P.Y. Barriat
+description: https://dev.to/nikolab/complete-list-of-github-markdown-emoji-markup-5aia
+backgroundImage: url('assets/back.png')
+_backgroundImage: url('assets/garde.png')
+footer: 05/05/2022 | Version control with Git
+_footer: ""
+paginate: true
+_paginate: false
+---
+
+Version control with `git` for scientists <!--fit-->
+===
+
+![h:150](assets/git.png)
+
+### PY Barriat & F. Massonnet
+
+##### May 05, 2022
+
+###### some parts inspired on slides from CISM
+
+---
+
+# Discuss :speech_balloon:
+
+### How do you manage different file versions :question:
+
+### How do you work with collaborators on the same files :question:
+
+###
+
+![h:250](assets/01.png)
+
+<!-- Notes for presenter. -->
+<!-- 
+Discussion sur l'intérêt du versioning
+-->
+
+---
+
+# Notions of code versioning
+
+## Track the history and evolution of the project
+
+think of it as a series of snapshots (**commits**) of your code
+
+### Benefits
+
+* possibility to go back in time :calendar:
+  > tracking bugs
+  > recovering from mistakes
+* Information about the modification :clipboard:
+  > who, when, why
+
+---
+
+- team work :busts_in_silhouette:
+  * **Simultaneous** work on a project
+    > No need to send email to say "I'm working on that file" (dropbox organization)
+  * **Asynchronous** synchronisation
+    > Allow work Offline (opposite to overleaf project)
+    > Need conflict resolution
+
+### Different usage
+
+* local
+* client-server (Subversion)
+* distributed (Git)
+
+---
+
+## Workflow
+
+**Testing new idea** (and easy way to throw them out) :construction:
+
+**Multiple version** of the code
+- Stable (1.x.y)
+- Debug (1.x.y+1)
+- Next "feature" release (1.x+1.0)
+- Next "huge" release (2.0.0)
+
+---
+
+# Open-Source Code
+
+### Compare Repositories
+
+![bg left 100%](assets/open_source_code.png)
+
+<!--```mermaid
+pie
+    "Git" : 73
+    "Mercurial" : 1
+    "Subversion (SVN)" : 22
+    "Bazaar" : 0
+    "CVS" : 1
+```-->
+
+<!-- _footer: "https://www.openhub.net/repositories/compare" -->
+
+---
+
+# What is `git` ?
+
+#### Version control system
+- Manage different versions of files
+- Collaborate with yourself
+- Collaborate with other people
+
+#### Why use `git`
+> *"Always remember your first collaborator is your future self, and your past self doesn't answer emails"*
+> Christie Balhai :wink:
+
+---
+
+# `git` workflow
+
+Your local repository consists of **three areas** maintained by `git`
+- the first one is your **Working Directory** which holds the actual files
+- the second one is the **INDEX** which acts as a staging area
+- and finally the **HEAD** which points to the last commit you've made
+
+![h:250](assets/06.png)
+
+---
+
+![bg 65%](assets/git_workflow.png)
+
+<!-- Notes for presenter. -->
+<!-- 
+Explications
+-->
+
+---
+
+# Getting started with `git`
+
+**checkout** a remote repository
+>create a local working copy of a remote repository
+
+```bash
+git clone https://gogs.elic.ucl.ac.be/TECLIM/Git_Training.git
+```
+
+**add** & **commit**
+> you can propose changes (add it to the **INDEX**)
+```bash
+git add <filename>
+```
+> you can commit these changes (to the **HEAD**)
+```bash
+git commit -m "Commit message"
+```
+
+---
+
+# commit
+
+`git` versioning is a succession of snapshot of your files at key time of their development
+
+each snapshot is called **commit** which is :
+
+- all the files at a given time
+- a unique name (SLHA1)
+- metadata
+  > who created, when, info
+- pointer to previous(es) commit(s)
+
+---
+
+Your changes are now in the **HEAD** of your local working copy. 
+
+**push**
+>to send those changes to your remote repository
+```bash
+git push
+```
+**pull**
+>to update your local working directory to the newest commit, to fetch and merge remote changes
+```bash
+git pull
+```
+
+---
+
+# `git` diff
+
+```mermaid
+sequenceDiagram
+%%autonumber
+    participant Workspace
+    participant INDEX
+    %%Note right of Workspace: Text in note
+    Workspace-->INDEX: git diff
+    INDEX-->HEAD: git diff --cached
+    Workspace-->HEAD: git diff HEAD
+```
+
+---
+
+# `git` undo
+
+In case you did something wrong (which for sure never happens :wink:) 
+
+```mermaid
+sequenceDiagram
+%%autonumber
+    participant Workspace
+    participant INDEX
+    Note over Workspace,INDEX: wrong modification of a file <br/>in your workspace
+    INDEX->>Workspace: git checkout -- file
+    %%HEAD-->Workspace: .<br/>
+    Note over Workspace,HEAD: wrong modification of a file <br/>that you put in your index
+    HEAD->>INDEX: git reset HEAD file
+    INDEX->>Workspace: git checkout -- file
+```
+---
+
+# Windows users
+
+> How commonly do programmers use Git GUIs instead of the command line ?
+
+Use programs like `SourceTree` or `TortoiseGit`
+
+![h:250](assets/07.png)
+
+But, **to be familiar with Git**, try the command line
+> clone, push/pull, merge, rebase, log, tag, format-patch/am, bisect, blame, etc
+
+---
+
+# Simple Git Exercices
+
+First, configure your environment (just once) :construction:
+> on your laptop, on your ELIC account, etc
+
+```bash
+git config --global user.name "Your Name"
+git config --global user.email "foo@bar.be"
+git config --global color.ui auto
+git config --global core.editor "vim"
+
+git config --list
+```
+Now, clone https://gogs.elic.ucl.ac.be/TECLIM/Git_Training.git
+> Theses are very simple exercices to learn to manipulate git.
+> In each folder, simply run `./create.sh` and follow the guide :sunglasses:
+
+---
+
+# `git` branches
+
+- a **branch** is pointer to a commit (represent an history)
+- a **branch** can point at other commit
+  > it can move !
+- a **branch** is a way to organize your work and working histories
+- since commit know which commits they are based on, **branch** represents a commit and what came before it
+- a branch is cheap, you can have multiple **branch** in the same repository and switch your working dir from one **branch** state to another
+
+---
+
+# branches demo
+
+```bash
+git commit
+git checkout -b newbranch
+git checkout newbranch
+git commit
+git commit
+git checkout master
+git commit
+git commit
+```
+> default branch: **master**
+
+```mermaid
+graph LR;
+    A[fffc93b] -->|commit| B(fc7f81f)
+    B -->|commit| D(6fd1a5a)
+    D -->|commit| E[newbranch <br/>187e6ab ]
+    B ---->|commit| Z(6ff4c2e)
+    Z -->|commit| Y[master <br/>c0f502f ]
+```
+---
+
+- create a new branch : `git checkout -b newbranch`
+- switch to a branch : `git checkout newbranch`
+- delete a branch : `git branch -d newbranch`
+- list all branches : `git branch`
+
+### branch is cheap : do it often :+1:
+> branch allow to have short/long term parallel development
+
+---
+
+# merging branches
+
+the interest of branch is that you can **merge** them
+> include in one (branch) file the modification done somewhere else
+
+```bash
+git merge bx
+git branch -d bx
+git commit
+```
+
+```mermaid
+graph LR;
+    A(fffc93b<br/>b_x) -->E[187e6ab<br/>b_x merged <br/>in b_y] 
+    D[6fd1a5a<br/>b_y] -->E
+    E -->|commit| Y[c0f502f<br/>b_y ]
+```
+---
+
+# Difference between `git` & `GitHub` ?
+
+`git` is the version control system **service**
+>git runs local if you don't use GitHub
+
+`GitHub` is the hosting service : **website**
+>on which you can publish (push) your git repositories and collaborate with other people
+
+---
+
+# `Github`
+
+- It provides a backup of your files
+- It gives you a visual interface for navigating your repos
+- It gives other people a way to navigate your repos
+- It makes repo collaboration easy (e.g., multiple people contributing to the same project)
+- It provides a lightweight issue tracking system
+
+---
+
+# ... and `GitLab` vs `GitHub` vs others
+
+`GitLab` is an alternative to `GitHub`
+> `GitLab` is free for unlimited private projects. `GitHub` doesn't provide private projects for free
+
+And for **ELIC**, `Gogs` does the job: https://gogs.elic.ucl.ac.be/
+- shares the same features 
+  > dashboard, file browser, issue tracking, groups support, webhooks, etc
+- easy to install, cross-platform friendly
+- uses little memory, uses little CPU power
+- ... and 100% free :smile:
+
+<!-- Notes for presenter. -->
+<!-- 
+Les goûts et les couleurs
+-->
+
+---
+
+# What is `git` good for ?
+
+#### Local
+
+> Backup, reproducibility
+
+![h:300](assets/02.png)
+
+---
+
+#### Client-Server
+
+> Backup, reproducibility, collaboration
+
+![h:500](assets/03.png)
+
+<!-- Notes for presenter. -->
+<!-- 
+Analogie à SVN
+-->
+
+---
+
+![bg 95%](assets/04.png)
+
+<!-- _footer: "**Limitation**" -->
+<!-- _paginate: "" -->
+
+<!-- Notes for presenter. -->
+<!-- 
+Explications
+-->
+
+---
+
+# `git` conflict :boom:
+
+### multiple version of files are great
+- not always easy to know how to merge them
+- conflict will happen (same line modify by both user)
+
+### conflict need to be resolved manually ! :fearful:
+- boring task
+- need to understand why a conflict is present !
+- **do not be afraid of conflict !** :muscle:
+  > Do not try to avoid them at all cost !
+- stay in sync as most as possible and keep line short
+
+---
+
+#### Distributed
+
+> Backup, reproducibility, collaboration, transparency
+
+![h:500](assets/05.png)
+
+<!-- _footer: "" -->
+
+---
+
+```mermaid
+sequenceDiagram
+autonumber
+    participant Workspace
+    participant INDEX
+    participant HEAD
+    participant Remote Repository
+    Remote Repository->>HEAD: clone
+    HEAD->>Workspace: checkout
+    %%Note over Workspace,Remote Repository: "clone" = clone + checkout
+    Workspace->>INDEX: add
+    INDEX->>HEAD: commit
+    Remote Repository->>HEAD: fetch
+    HEAD->>Workspace: merge
+    Remote Repository->>Workspace: pull
+    %%Note over Workspace,Remote Repository: pull = fetch + merge
+    HEAD->>Remote Repository: push
+```
+
+<!-- _footer: "Summary of operations" -->
+
+
+<!-- Notes for presenter. -->
+<!-- 
+"clone" = clone + checkout
+
+pull = fetch + merge
+-->
+
+---
+
+# Conclusion
+
+- **versioning** is crucial both for small/large project :exclamation:
+- avoid dropbox for paper / project :confounded:
+- do meaningful commit
+- do meaningful message
+- `git` more complicated but the standard :smiley:
+
+---
+
+# Version control with Git for scientists :chart_with_upwards_trend:

BIN
slides/git_elic.pdf


Some files were not shown because too many files changed in this diff