Commit 3e7b7c32 authored by Nicolas Descostes's avatar Nicolas Descostes
Browse files

intro

parent f11e9407
# introduction-git-bioIT-workshop
# Introduction to git
This is the material for the introduction to git workshop initially held on the 10th of December 2019
\ No newline at end of file
## Table of content
1. [Introduction](#introduction)
**Contributors:** Nicolas Descostes and Toby Hodges
**Credits:** This content is largely based on the [GBCS](https://gbcs.embl.de/portal/tiki-index.php) [tutorial](https://gbservices.embl.de/git-conda/) and the [Software Carpentry](https://software-carpentry.org/) [tutorial](https://swcarpentry.github.io/git-novice/).
The Software Carpentry content being under CC-BY 4.0 license and GBCS having kindly given their authorization to use their material, a lot of the material in this workshop are just copied/pasted.
## Introduction
Let's begin by having a look at what a life without git looks like:
[manuscript1](pictures/intro1.jpeg)
[1](https://medium.com/@fredrick.adegoke/version-control-systems-source-code-banking-efcbb9272aee)
[manuscript2](pictures/intro2.jpeg)
[2](http://www.phdcomics.com)
Git can not only prevent you experiencing these situations but also help you programming more efficiently:
[badpractice](pictures/intro3.jpeg)
[3](http://www.phdcomics.com)
Version control systems start with a base version of the document and then record changes you make each step of the way. You can think of it as a recording of your progress: you can rewind to start at the base document and play back each change you made, eventually arriving at your more recent version.
[modification1](pictures/intro4.jpeg)
Once you think of changes as separate from the document itself, you can then think about “playing back” different sets of changes on the base document, ultimately resulting in different versions of that document. For example, two users can make independent sets of changes on the same document. Git enables collaborative work! Several people can work on the same document or the same program!
[modification2](pictures/intro5.jpeg)
Unless multiple users make changes to the same section of the document - a conflict - you can incorporate two sets of changes into the same base document.
[modification3](pictures/intro6.jpeg)
A version control system is a tool that keeps track of these changes for us, effectively creating different versions of our files. It allows us to decide which changes will be made to the next version (each record of these changes is called a commit), and keeps useful metadata about them. The complete history of commits for a particular project and their metadata make up a repository. Repositories can be kept in sync across different computers, facilitating collaboration among different people.
Automated version control systems are nothing new. Tools like RCS, CVS, or Subversion have been around since the early 1980s and are used by many large companies. However, many of these are now considered legacy systems (i.e., outdated) due to various limitations in their capabilities. More modern systems, such as Git and Mercurial, are distributed, meaning that they do not need a centralized server to host the repository. These modern systems also include powerful merging tools that make it possible for multiple authors to work on the same files concurrently.
**Key points:**
* Version control is like an unlimited ‘undo’.
* Version control also allows many people to work in parallel.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## The GitLab Interface & First Steps
- log into git.embl.de
- show an example project
- highlight key parts of project interface
- show project history timeline
- show blame for a single file
- show how to view older versions of a file
- create a project from scratch
- add a README.md
- introduce basics of Markdown
- make a change to README via web interface
- commit and explain commit message
- repeat
- add new file(s)
## Working on the command line
- navigate to relevant directory
- clone repo && cd into project directory
- change global settings
- `git config --global user.name`
- `git config --global user.email`
- `git config --global core.editor "nano -w"`
- mention `git init` - demo this at the end of day
- `git status`
- `git log`
- edit/create a file
- `git add`
- `git commit`
- (if necessary) more about commit messages
- imagine your future self as a collaborator, who won't know (remember) why you made the changes you're making
- make another change
- `git add`
- `git commit -m`
- mention `git commit -a` & warn about hazards of using it
- `git log`
- `git log -N`
- `git log --oneline`
- `git log --patch <filename>`
- `git diff`
- `git add + git diff --staged`
- `git diff --color-words`
- `git diff HEAD~2 <filename>`
- `git diff <commithash> <filename>`
- `git checkout HEAD` to revert to most recent committed state
- `git checkout HEAD <filename>` to achieve the same thing with a single file
- detached head!
- `git checkout <commithash>` (forgetting filename)
- `git checkout master` to recover from this
- `.gitignore`
- remotes
- `git remote`
- `git push origin master`
- make a change on GitLab
- `git pull origin master`
- collaboration exercises
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="615px"
height="196.5px" viewBox="0 0 615 196.5" enable-background="new 0 0 615 196.5" xml:space="preserve">
<g id="Layer_1">
<g>
<defs>
<rect id="SVGID_1_" x="34.52" y="28.419" width="104" height="131.217"/>
</defs>
<clipPath id="SVGID_2_">
<use xlink:href="#SVGID_1_" overflow="visible"/>
</clipPath>
<rect x="37" y="30" clip-path="url(#SVGID_2_)" fill="#DCDEE0" width="100" height="128"/>
<rect x="37" y="30" clip-path="url(#SVGID_2_)" fill="none" stroke="#85888D" stroke-width="2" width="100" height="128"/>
</g>
<g>
<defs>
<rect id="SVGID_3_" x="48.635" y="48.268" width="75.805" height="4"/>
</defs>
<clipPath id="SVGID_4_">
<use xlink:href="#SVGID_3_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_4_)" fill="none" stroke="#000000" stroke-width="2" x1="50" y1="50" x2="123" y2="50"/>
</g>
<g>
<defs>
<rect id="SVGID_5_" x="48.635" y="54.097" width="75.805" height="4"/>
</defs>
<clipPath id="SVGID_6_">
<use xlink:href="#SVGID_5_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_6_)" fill="none" stroke="#000000" stroke-width="2" x1="50" y1="56" x2="123" y2="56"/>
</g>
<g>
<defs>
<rect id="SVGID_7_" x="48.635" y="59.926" width="75.805" height="4"/>
</defs>
<clipPath id="SVGID_8_">
<use xlink:href="#SVGID_7_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_8_)" fill="none" stroke="#000000" stroke-width="2" x1="50" y1="62" x2="123" y2="62"/>
</g>
<g>
<defs>
<rect id="SVGID_9_" x="48.635" y="71.585" width="75.805" height="4"/>
</defs>
<clipPath id="SVGID_10_">
<use xlink:href="#SVGID_9_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_10_)" fill="none" stroke="#000000" stroke-width="2" x1="50" y1="74" x2="123" y2="74"/>
</g>
<g>
<rect x="258" y="30" fill="#DCDEE0" width="100" height="128"/>
<rect x="258" y="30" fill="none" stroke="#85888D" stroke-width="2" width="100" height="128"/>
<line fill="none" stroke="#000000" stroke-width="2" x1="272" y1="50" x2="345" y2="50"/>
<line fill="none" stroke="#000000" stroke-width="2" x1="272" y1="56" x2="345" y2="56"/>
<line fill="none" stroke="#000000" stroke-width="2" x1="272" y1="62" x2="345" y2="62"/>
<line fill="none" stroke="#70BF41" stroke-width="2" x1="272" y1="74" x2="345" y2="74"/>
<line fill="none" stroke="#70BF41" stroke-width="2" x1="160" y1="55" x2="234" y2="55"/>
<rect x="481" y="31" fill="#DCDEE0" width="100" height="128"/>
<rect x="481" y="31" fill="none" stroke="#85888D" stroke-width="2" width="100" height="128"/>
<line fill="none" stroke="#000000" stroke-width="2" x1="495" y1="51" x2="568" y2="51"/>
<line fill="none" stroke="#000000" stroke-width="2" x1="495" y1="57" x2="568" y2="57"/>
<line fill="none" stroke="#000000" stroke-width="2" x1="495" y1="63" x2="568" y2="63"/>
<line fill="none" stroke="#70BF41" stroke-width="2" x1="495" y1="75" x2="568" y2="75"/>
<line fill="none" stroke="#70BF41" stroke-width="2" x1="495" y1="86" x2="568" y2="86"/>
<line fill="none" stroke="#70BF41" stroke-width="2" x1="495" y1="92" x2="568" y2="92"/>
<line fill="none" stroke="#70BF41" stroke-width="2" x1="495" y1="98" x2="568" y2="98"/>
<line fill="none" stroke="#70BF41" stroke-width="2" x1="383" y1="49" x2="457" y2="49"/>
<line fill="none" stroke="#70BF41" stroke-width="2" x1="383" y1="55" x2="457" y2="55"/>
<line fill="none" stroke="#70BF41" stroke-width="2" x1="383" y1="61" x2="457" y2="61"/>
<g>
<defs>
<rect id="SVGID_11_" x="157.116" y="65.521" width="88.974" height="66.13"/>
</defs>
<clipPath id="SVGID_12_">
<use xlink:href="#SVGID_11_" overflow="visible"/>
</clipPath>
</g>
</g>
<g>
<g>
<defs>
<rect id="SVGID_13_" x="-203" y="-477" width="1024" height="768"/>
</defs>
<clipPath id="SVGID_14_">
<use xlink:href="#SVGID_13_" overflow="visible"/>
</clipPath>
</g>
</g>
<g>
<g>
<defs>
<rect id="SVGID_15_" x="375.494" y="73.597" width="88.974" height="66.129"/>
</defs>
<clipPath id="SVGID_16_">
<use xlink:href="#SVGID_15_" overflow="visible"/>
</clipPath>
</g>
</g>
<g opacity="0.5">
<rect x="163.931" y="85.276" fill="#009CFD" width="44.865" height="26.919"/>
<g>
<polygon fill="#009CFD" points="200.941,125.429 239.275,98.588 200.941,71.743 "/>
</g>
</g>
<g opacity="0.5">
<rect x="383.016" y="85.276" fill="#009CFD" width="44.865" height="26.919"/>
<g>
<polygon fill="#009CFD" points="420.026,125.429 458.359,98.588 420.026,71.743 "/>
</g>
</g>
</g>
<g id="Layer_2">
</g>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="384px" height="354px" viewBox="0 0 384 354" enable-background="new 0 0 384 354" xml:space="preserve">
<g>
<defs>
<rect id="SVGID_1_" x="31.218" y="108.841" width="104" height="131.216"/>
</defs>
<clipPath id="SVGID_2_">
<use xlink:href="#SVGID_1_" overflow="visible"/>
</clipPath>
<rect x="33" y="111" clip-path="url(#SVGID_2_)" fill="#DCDEE0" width="100" height="127"/>
<rect x="33" y="111" clip-path="url(#SVGID_2_)" fill="none" stroke="#85888D" stroke-width="2" width="100" height="127"/>
</g>
<g>
<defs>
<rect id="SVGID_3_" x="45.334" y="128.688" width="75.805" height="4"/>
</defs>
<clipPath id="SVGID_4_">
<use xlink:href="#SVGID_3_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_4_)" fill="none" stroke="#000000" stroke-width="2" x1="46" y1="131" x2="120" y2="131"/>
</g>
<g>
<defs>
<rect id="SVGID_5_" x="45.334" y="134.519" width="75.805" height="4"/>
</defs>
<clipPath id="SVGID_6_">
<use xlink:href="#SVGID_5_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_6_)" fill="none" stroke="#000000" stroke-width="2" x1="46" y1="137" x2="120" y2="137"/>
</g>
<g>
<defs>
<rect id="SVGID_7_" x="45.334" y="140.348" width="75.805" height="4"/>
</defs>
<clipPath id="SVGID_8_">
<use xlink:href="#SVGID_7_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_8_)" fill="none" stroke="#000000" stroke-width="2" x1="46" y1="142" x2="120" y2="142"/>
</g>
<g>
<defs>
<rect id="SVGID_9_" x="45.334" y="152.006" width="75.805" height="4"/>
</defs>
<clipPath id="SVGID_10_">
<use xlink:href="#SVGID_9_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_10_)" fill="none" stroke="#000000" stroke-width="2" x1="46" y1="154" x2="120" y2="154"/>
</g>
<g>
<defs>
<rect id="SVGID_11_" x="253.198" y="21.402" width="104" height="131.216"/>
</defs>
<clipPath id="SVGID_12_">
<use xlink:href="#SVGID_11_" overflow="visible"/>
</clipPath>
<rect x="255" y="23" clip-path="url(#SVGID_12_)" fill="#DCDEE0" width="100" height="128"/>
<rect x="255" y="23" clip-path="url(#SVGID_12_)" fill="none" stroke="#85888D" stroke-width="2" width="100" height="128"/>
</g>
<g>
<defs>
<rect id="SVGID_13_" x="267.314" y="41.25" width="75.805" height="4"/>
</defs>
<clipPath id="SVGID_14_">
<use xlink:href="#SVGID_13_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_14_)" fill="none" stroke="#000000" stroke-width="2" x1="268" y1="43" x2="342" y2="43"/>
</g>
<g>
<defs>
<rect id="SVGID_15_" x="267.314" y="47.08" width="75.805" height="4"/>
</defs>
<clipPath id="SVGID_16_">
<use xlink:href="#SVGID_15_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_16_)" fill="none" stroke="#000000" stroke-width="2" x1="268" y1="49" x2="342" y2="49"/>
</g>
<g>
<defs>
<rect id="SVGID_17_" x="267.314" y="52.909" width="75.805" height="4"/>
</defs>
<clipPath id="SVGID_18_">
<use xlink:href="#SVGID_17_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_18_)" fill="none" stroke="#000000" stroke-width="2" x1="268" y1="55" x2="342" y2="55"/>
</g>
<g>
<defs>
<rect id="SVGID_19_" x="267.314" y="64.567" width="75.805" height="4"/>
</defs>
<clipPath id="SVGID_20_">
<use xlink:href="#SVGID_19_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_20_)" fill="none" stroke="#70BF41" stroke-width="2" x1="268" y1="67" x2="342" y2="67"/>
</g>
<g>
<defs>
<rect id="SVGID_21_" x="155.796" y="57.292" width="75.806" height="4"/>
</defs>
<clipPath id="SVGID_22_">
<use xlink:href="#SVGID_21_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_22_)" fill="none" stroke="#70BF41" stroke-width="2" x1="157" y1="59" x2="231" y2="59"/>
</g>
<polygon fill="#45BEEE" points="203.427,125.067 207.724,139.122 237.382,98.616 190.144,81.62 194.44,95.675 153.541,108.179
162.527,137.571 "/>
<g>
<defs>
<rect id="SVGID_23_" x="253.198" y="201.382" width="104" height="131.216"/>
</defs>
<clipPath id="SVGID_24_">
<use xlink:href="#SVGID_23_" overflow="visible"/>
</clipPath>
<rect x="255" y="203" clip-path="url(#SVGID_24_)" fill="#DCDEE0" width="100" height="128"/>
<rect x="255" y="203" clip-path="url(#SVGID_24_)" fill="none" stroke="#85888D" stroke-width="2" width="100" height="128"/>
</g>
<g>
<defs>
<rect id="SVGID_25_" x="267.314" y="221.229" width="75.805" height="4"/>
</defs>
<clipPath id="SVGID_26_">
<use xlink:href="#SVGID_25_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_26_)" fill="none" stroke="#000000" stroke-width="2" x1="268" y1="223" x2="342" y2="223"/>
</g>
<g>
<defs>
<rect id="SVGID_27_" x="267.314" y="227.059" width="75.805" height="4"/>
</defs>
<clipPath id="SVGID_28_">
<use xlink:href="#SVGID_27_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_28_)" fill="none" stroke="#000000" stroke-width="2" x1="268" y1="229" x2="342" y2="229"/>
</g>
<g>
<defs>
<rect id="SVGID_29_" x="267.314" y="232.888" width="75.805" height="4"/>
</defs>
<clipPath id="SVGID_30_">
<use xlink:href="#SVGID_29_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_30_)" fill="none" stroke="#000000" stroke-width="2" x1="268" y1="235" x2="342" y2="235"/>
</g>
<g>
<defs>
<rect id="SVGID_31_" x="267.314" y="244.547" width="75.805" height="4"/>
</defs>
<clipPath id="SVGID_32_">
<use xlink:href="#SVGID_31_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_32_)" fill="none" stroke="#C82506" stroke-width="2" x1="268" y1="247" x2="342" y2="247"/>
</g>
<polygon fill="#45BEEE" points="194.44,238.713 190.144,252.767 237.382,235.771 207.724,195.266 203.427,209.32 162.527,196.815
153.541,226.208 "/>
<g>
<defs>
<rect id="SVGID_33_" x="267.314" y="250.547" width="75.805" height="4"/>
</defs>
<clipPath id="SVGID_34_">
<use xlink:href="#SVGID_33_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_34_)" fill="none" stroke="#C82506" stroke-width="2" x1="268" y1="253" x2="342" y2="253"/>
</g>
<g>
<defs>
<rect id="SVGID_35_" x="156.559" y="265.692" width="75.806" height="4"/>
</defs>
<clipPath id="SVGID_36_">
<use xlink:href="#SVGID_35_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_36_)" fill="none" stroke="#C82506" stroke-width="2" x1="158" y1="268" x2="231" y2="268"/>
</g>
<g>
<defs>
<rect id="SVGID_37_" x="156.559" y="271.692" width="75.806" height="4"/>
</defs>
<clipPath id="SVGID_38_">
<use xlink:href="#SVGID_37_" overflow="visible"/>
</clipPath>
<line clip-path="url(#SVGID_38_)" fill="none" stroke="#C82506" stroke-width="2" x1="158" y1="274" x2="231" y2="274"/>
</g>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="398px" height="382px" viewBox="0 0 398 382" enable-background="new 0 0 398 382" xml:space="preserve">
<g>
<rect x="266" y="129" fill="#DCDEE0" width="100" height="127"/>
<rect x="266" y="129" fill="none" stroke="#85888D" stroke-width="2" width="100" height="127"/>
<line fill="none" stroke="#000000" stroke-width="2" x1="279" y1="149" x2="353" y2="149"/>
<line fill="none" stroke="#000000" stroke-width="2" x1="279" y1="155" x2="353" y2="155"/>
<line fill="none" stroke="#000000" stroke-width="2" x1="279" y1="160" x2="353" y2="160"/>
<line fill="none" stroke="#70BF41" stroke-width="2" x1="279" y1="172" x2="353" y2="172"/>
<rect x="32" y="41" fill="#DCDEE0" width="100" height="128"/>
<rect x="32" y="41" fill="none" stroke="#85888D" stroke-width="2" width="100" height="128"/>
<line fill="none" stroke="#000000" stroke-width="2" x1="45" y1="61" x2="119" y2="61"/>
<line fill="none" stroke="#000000" stroke-width="2" x1="45" y1="67" x2="119" y2="67"/>
<line fill="none" stroke="#000000" stroke-width="2" x1="45" y1="73" x2="119" y2="73"/>
<line fill="none" stroke="#70BF41" stroke-width="2" x1="45" y1="85" x2="119" y2="85"/>
<line fill="none" stroke="#70BF41" stroke-width="2" x1="162" y1="155" x2="236" y2="155"/>
</g>
<g>
<rect x="32" y="221" fill="#DCDEE0" width="100" height="128"/>
<rect x="32" y="221" fill="none" stroke="#85888D" stroke-width="2" width="100" height="128"/>
<line fill="none" stroke="#000000" stroke-width="2" x1="45" y1="241" x2="119" y2="241"/>
<line fill="none" stroke="#000000" stroke-width="2" x1="45" y1="247" x2="119" y2="247"/>
<line fill="none" stroke="#000000" stroke-width="2" x1="45" y1="253" x2="119" y2="253"/>
<line fill="none" stroke="#C82506" stroke-width="2" x1="45" y1="265" x2="119" y2="265"/>
</g>
<polygon fill="#45BEEE" points="205.711,272.768 210.008,286.822 239.666,246.316 192.428,229.32 196.725,243.375 155.825,255.879
164.812,285.271 "/>
<polygon fill="#45BEEE" points="197.488,131.384 193.191,145.438 240.43,128.443 210.771,87.937 206.475,101.992 165.574,89.487
156.588,118.88 "/>
<g>
<line fill="none" stroke="#C82506" stroke-width="2" x1="45" y1="271" x2="119" y2="271"/>
<line fill="none" stroke="#C82506" stroke-width="2" x1="162" y1="208" x2="236" y2="208"/>
<line fill="none" stroke="#C82506" stroke-width="2" x1="162" y1="214" x2="236" y2="214"/>
<line fill="none" stroke="#C82506" stroke-width="2" x1="279" y1="179" x2="353" y2="179"/>
<line fill="none" stroke="#C82506" stroke-width="2" x1="279" y1="185" x2="353" y2="185"/>
</g>
</svg>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment