From 6001317b9e1223f81af3e5fdcce7e1d7bfbfbe73 Mon Sep 17 00:00:00 2001 From: Sylvain Arreckx <sylvain.arreckx@gmail.com> Date: Tue, 17 Jan 2017 12:14:31 +0100 Subject: [PATCH] Pass over all slides. --- best_practices.md | 24 ++++++++++++------------ branches.md | 18 ++++++++++-------- essential_commands.md | 28 ++++++++++++++-------------- forks.md | 27 ++++++++++++++------------- github_gitlab.md | 5 +++++ installation.md | 20 ++++++++++---------- thanks.md | 26 ++++++++++++++++++-------- the_terminal.md | 20 ++++++++++---------- 8 files changed, 93 insertions(+), 75 deletions(-) diff --git a/best_practices.md b/best_practices.md index 6b6440ff..684c5c0b 100644 --- a/best_practices.md +++ b/best_practices.md @@ -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> diff --git a/branches.md b/branches.md index 5e9ac0ed..d4cd1f0f 100644 --- a/branches.md +++ b/branches.md @@ -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/). diff --git a/essential_commands.md b/essential_commands.md index 944f03a7..25aa3f01 100644 --- a/essential_commands.md +++ b/essential_commands.md @@ -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 diff --git a/forks.md b/forks.md index 981bd634..cdc7b67b 100644 --- a/forks.md +++ b/forks.md @@ -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`  ## 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 ``` diff --git a/github_gitlab.md b/github_gitlab.md index a4b2cfb0..ea5e300d 100644 --- a/github_gitlab.md +++ b/github_gitlab.md @@ -1,5 +1,8 @@ ## 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) diff --git a/installation.md b/installation.md index ed949154..ba609597 100644 --- a/installation.md +++ b/installation.md @@ -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. diff --git a/thanks.md b/thanks.md index e234bf21..62ab5a8b 100644 --- a/thanks.md +++ b/thanks.md @@ -1,15 +1,25 @@ -## 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) - -Sylvain Arreckx - +## 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></th> + <th></th> + </tr> + <tr> + <th>Laurent Heirendt</th> + <th>Sylvain Arreckx</th> + </tr> + +</table> diff --git a/the_terminal.md b/the_terminal.md index a4ead768..833454e7 100644 --- a/the_terminal.md +++ b/the_terminal.md @@ -1,14 +1,14 @@ ## 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 ``` -- GitLab