<style type="text/css">
.reveal section img { background:none; border:none; box-shadow:none; }
</style>
### Coffee Lecture 01 : Learn the Basics of Git in under 10 Minutes
<small>
Antoine Masson, PhD @amasson_epfl
![](https://minio.youmi-lausanne.ch:443/hmd.youmi/uploads/upload_9d9b733cb3f4e7b73ff9d9ffb8ecff37.png =100x) ![](https://minio.youmi-lausanne.ch:443/hmd.youmi/uploads/upload_fdb45ac900f0b8ea51f4aa0196b9e260.png =100x)
| This presentation : <BR/> https://go.epfl.ch/libcof01 |![](https://minio.youmi-lausanne.ch/hmd.youmi/uploads/upload_127b3759297c1aa8f1feaf7ed2c1ccac.png =100x)|
| -------- | -------- |
</small>
---
For this coffee lecture, the learning objectives are:
- Learn what is a version control system like git and why you need to use one
- Learn how to start with git and where to find information to continue
---
## What is Version Control?
---
### Versioning for safer work
* Going back in case of unwanted modification
* Keep track of team work
---
### Versioning for citation
* Reference the version used for the publication
* Branches for different state of work
---
### Versioning for collaboration
* Keep track of team work
* Manage conflicts
* Unit test, compilation test...
Note: remember that many software include versioning features (code management : git, document management : word, sharepoint, wikis...)
---
## What is git ?
---
### Save operations on files
| Intial state | Added a line | Update a line |
| ------------ | ------------ | ------------- |
| ![](https://minio.youmi-lausanne.ch/hmd.youmi/uploads/upload_ccd30af761258823dd052138420eaec0.png) | ![](https://minio.youmi-lausanne.ch/hmd.youmi/uploads/upload_c12730c18655de1a555d04a57100337f.png) | ![](https://minio.youmi-lausanne.ch/hmd.youmi/uploads/upload_a19ae3e6d3cb758b12f8777d2a436f51.png)
---
### What git can do? (briefely)
- Git will keep track of changes in each files (added/updated/removed line(s)), but also who, when and why (comments)
- Changes can be distributed to others
- Possible to create different project versions (branches)
---
## How to use git?
---
### How to install git
- Windows : [Download the Git for Windows installer](https://gitforwindows.org/). [More info](https://carpentries.github.io/workshop-template/#shell)
- MacOS : Already installed, use terminal. [More info](https://carpentries.github.io/workshop-template/#shell)
- Linux : Install ```git```package. [More info](https://carpentries.github.io/workshop-template/#shell)
---
### Run git
- Git runs in command line
- Possible to use a graphical interface (GUI) for exemple [GitKraken](https://www.gitkraken.com/)
---
- Windows, Use ```Git Bash```: ![](https://minio.youmi-lausanne.ch/hmd.youmi/uploads/upload_8efae392b7a809e9eb064948ad0f4784.png)
- MacOS and Linux : Open terminal
---
Hands-on
---
### Commands used in this training
<small>
__All commands start by ```git```__
| Command | Action |
| ---------------------------------- | ---------------------------------------------- |
| ```init``` | Initiate git in the working directory |
| ```status``` | return git health and status |
| ```add``` | add file(s) to commit |
| ```commit -m _commitcomment_``` | do the commit and description |
| ```log``` | commit history |
| ```diff``` | return file(s) modifications |
| ```checkout _commit_ _filename_``` | Restore a file like it was at the given commit |
</small>
---
### Links
- [How to use Bash : Software carpentry](https://swcarpentry.github.io/shell-novice/)
- [How to use Bash : Wikihow](https://www.wikihow.com/Use-Bash)
- [How to use GIT : Software carpentry](https://swcarpentry.github.io/git-novice/)
- [How to use GIT : freecodecamp](https://www.freecodecamp.org/news/learn-the-basics-of-git-in-under-10-minutes-da548267cc91/)
- [Good pratices with software devlopment : The Turing way book](https://the-turing-way.netlify.app/reproducible-research/reproducible-research.html)
---
## Thank you
Next Coffee Lecture : _Pro-tips to enhance your research equations_ 10/11 at 10h. [To know more](http://go.epfl.ch/coffee-lectures)
<small> License : CC-BY (Antoine Masson EPFL Library)</small>
{"slideOptions":{"transition":"fade","progress":true,"border":"none","theme":"serif"},"title":"Coffee Lecture 01 Learn the Basics of Git in under 10 Minutes","tags":"course, RDM, open source"}