![Page 1: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/1.jpg)
Introduction to git
Joachim Desroches
GNU Generation
2018-10-01
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 1 / 14
![Page 2: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/2.jpg)
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 2 / 14
![Page 3: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/3.jpg)
Table of Contents
1 The Problem
2 About git
3 Using git
4 Collaborate
5 Common mistakes
6 Practice time
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 3 / 14
![Page 4: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/4.jpg)
The Problem
Version Hell
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 4 / 14
![Page 5: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/5.jpg)
About git
Version Control
Make the computer do the work.
Several exist: git, SVN, CVS, Mercurial...
Git created to track Linux kernel, most commonly used.
Do NOT confuse with project management systems like MicrosoftGithub or Gitlab!
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 5 / 14
![Page 6: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/6.jpg)
About git
Version Control
Make the computer do the work.
Several exist: git, SVN, CVS, Mercurial...
Git created to track Linux kernel, most commonly used.
Do NOT confuse with project management systems like MicrosoftGithub or Gitlab!
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 5 / 14
![Page 7: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/7.jpg)
About git
Version Control
Make the computer do the work.
Several exist: git, SVN, CVS, Mercurial...
Git created to track Linux kernel, most commonly used.
Do NOT confuse with project management systems like MicrosoftGithub or Gitlab!
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 5 / 14
![Page 8: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/8.jpg)
About git
Version Control
Make the computer do the work.
Several exist: git, SVN, CVS, Mercurial...
Git created to track Linux kernel, most commonly used.
Do NOT confuse with project management systems like MicrosoftGithub or Gitlab!
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 5 / 14
![Page 9: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/9.jpg)
Using git
Tracking changes
Let us start locally. There are three things you want to do:
Start using git! git init . and git status
Add and save changes: git add <file> and git commit
Review changes: git log, git diff and git checkout
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 6 / 14
![Page 10: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/10.jpg)
Using git
Tracking changes
Let us start locally. There are three things you want to do:
Start using git! git init . and git status
Add and save changes: git add <file> and git commit
Review changes: git log, git diff and git checkout
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 6 / 14
![Page 11: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/11.jpg)
Using git
Tracking changes
Let us start locally. There are three things you want to do:
Start using git! git init . and git status
Add and save changes: git add <file> and git commit
Review changes: git log, git diff and git checkout
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 6 / 14
![Page 12: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/12.jpg)
Collaborate
And then they were two
What happens if there are several of us ?
Needs some centrally accessible machine.
Helps to use a frontend like Gitlab.
Interacting: git push, git pull, merging.
We will see this in more detail in the practical part.
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 7 / 14
![Page 13: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/13.jpg)
Collaborate
And then they were two
What happens if there are several of us ?
Needs some centrally accessible machine.
Helps to use a frontend like Gitlab.
Interacting: git push, git pull, merging.
We will see this in more detail in the practical part.
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 7 / 14
![Page 14: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/14.jpg)
Collaborate
And then they were two
What happens if there are several of us ?
Needs some centrally accessible machine.
Helps to use a frontend like Gitlab.
Interacting: git push, git pull, merging.
We will see this in more detail in the practical part.
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 7 / 14
![Page 15: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/15.jpg)
Collaborate
And then they were two
What happens if there are several of us ?
Needs some centrally accessible machine.
Helps to use a frontend like Gitlab.
Interacting: git push, git pull, merging.
We will see this in more detail in the practical part.
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 7 / 14
![Page 16: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/16.jpg)
Common mistakes
Some confusions that occur often
Trying to remove things from git.
Trying to modify a commit when history is shared.
Not fixing conflicts properly.
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 8 / 14
![Page 17: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/17.jpg)
Common mistakes
Some confusions that occur often
Trying to remove things from git.
Trying to modify a commit when history is shared.
Not fixing conflicts properly.
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 8 / 14
![Page 18: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/18.jpg)
Common mistakes
Some confusions that occur often
Trying to remove things from git.
Trying to modify a commit when history is shared.
Not fixing conflicts properly.
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 8 / 14
![Page 19: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/19.jpg)
Practice time
Please pair up! (Groups of 3 are ok) Then head over tohttp://gitlab.gnugen.ch
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 9 / 14
![Page 20: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/20.jpg)
Practice time
One of you should create a new project, choosing to initialize it with aREADME and add the other as at least a developper. Then follow theinstructions to clone the repository on your machines.
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 10 / 14
![Page 21: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/21.jpg)
Practice time
Make some changes each, and track them! Remember, you can use:
git add <myfile> in order to set a changed file in this snapshot.
git commit to snapshot the files.
git log to see what has happened until now.
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 11 / 14
![Page 22: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/22.jpg)
Practice time
Now, one of you can use git push to send his work to the server. Go thewebpage of your project, and see that you can indeed see the changes.The second should try to push as well: does this work ?
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 12 / 14
![Page 23: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/23.jpg)
Practice time
git pull: you will start a merge.
git status, git add to resolve: open the files and look for lineswith >>>>>,===== and <<<<<<<.
Finally use git commit to finish, and push your changes!
Your partner can now pull: this time, there should be no conflict.
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 13 / 14
![Page 24: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/24.jpg)
Practice time
git pull: you will start a merge.
git status, git add to resolve: open the files and look for lineswith >>>>>,===== and <<<<<<<.
Finally use git commit to finish, and push your changes!
Your partner can now pull: this time, there should be no conflict.
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 13 / 14
![Page 25: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/25.jpg)
Practice time
git pull: you will start a merge.
git status, git add to resolve: open the files and look for lineswith >>>>>,===== and <<<<<<<.
Finally use git commit to finish, and push your changes!
Your partner can now pull: this time, there should be no conflict.
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 13 / 14
![Page 26: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/26.jpg)
Practice time
Conclusion
Remember man pages are your friend!
Read the Git Book: more depth and more possibilities
Most of all, use git! Practice makes perfect.
Questions ?
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 14 / 14
![Page 27: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/27.jpg)
Practice time
Conclusion
Remember man pages are your friend!
Read the Git Book: more depth and more possibilities
Most of all, use git! Practice makes perfect.
Questions ?
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 14 / 14
![Page 28: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/28.jpg)
Practice time
Conclusion
Remember man pages are your friend!
Read the Git Book: more depth and more possibilities
Most of all, use git! Practice makes perfect.
Questions ?
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 14 / 14
![Page 29: Introduction to git - gnugeneration.epfl.chdesroche/... · Table of Contents 1 The Problem 2 About git 3 Using git 4 Collaborate 5 Common mistakes 6 Practice time Joachim Desroches](https://reader036.vdocuments.net/reader036/viewer/2022081400/5f188e8f9e78e12e935047c3/html5/thumbnails/29.jpg)
Practice time
Conclusion
Remember man pages are your friend!
Read the Git Book: more depth and more possibilities
Most of all, use git! Practice makes perfect.
Questions ?
Joachim Desroches (GNU Generation) Introduction to git 2018-10-01 14 / 14