Git Intro
Git Intro
Thomas Breuer
1 / 11
Aim of this talk
2 / 11
Version control systems – why?
• (for software development, writing papers, . . . )
3 / 11
Git
. . . is free,
. . . has GUIs, but here we show just the command line version,
4 / 11
A live session with git
(commands in order of appearance)
git init,
git status,
git add <<files>>,
git commit,
git log,
git diff,
git diff --cached,
git diff <<old>> <<new>>,
git branch,
git checkout <<branch>>,
git merge <<branch>>,
git stash,
git stash pop.
5 / 11
GitHub: Use remote repositories
We interact with GitHub via the command line and via a web interface.
6 / 11
Proposed GitHub workflow
Do not directly merge your changes into the (central) remote
repository.
fork
central - user’s
remote remote
pull request
6
@ push clone
pull @ ?
@
R
@
user’s
local
7 / 11
Proposed GitHub workflow: Setup
• Make sure that you have a GitHub account, and that local user
name and e-mail address fit to the values of the account.
Check with git config -l,
set with git config user.name "..." and
git config user.email "...".
• Create/take a central remote repository. (Here:
https://github.com/oscar-system/Summerschool21Exercises.jl)
• Create your own remote copy via fork.
(Click the button in the web page of the repository.)
• Create your own local copy via clone.
(Copy the URL under Code/Clone in the web page,
then execute git clone with this URL on your computer.)
• Notify the central remote repository. On your computer, call:
git remote add upstream <<url-central>>.
(Check with git remote -v.)
Now git pull -r upstream main should work.
8 / 11
Proposed Github workflow: Repeat
• In your local repository,
• create a new branch (git checkout -b <<name>>),
• edit some files,
• stage the changed files (git add),
• commit the changes (git commit),
• incorporate changes in the remote main branch
since you started editing (git pull -r upstream main;
-r means “rebase”: rewrite the history such that
the remote changes come first and the local changes come on top),
• commit the updated version,
• and then push the new version to origin (git push;
git will propose additional parameters).
• In the web page of the central remote repository,
GitHub will propose to create a pull request.
Check that these are the changes you want to propose;
if not then go to the previous step.
Edit the description if necessary.
Finally, create the pull request.
9 / 11
Proposed workflow: Repeat
10 / 11
Some links
git documentation
• man git, man giteveryday, man gittutorial
• Reference Manual: https://git-scm.com/doc
• Cheat sheet:
https://education.github.com/git-cheat-sheet-education.pdf
GitHub documentation
• Documentation: https://docs.github.com
• Tutorial:
https://product.hubspot.com/blog/git-and-github-
tutorial-for-beginners
Markdown syntax
• Documentation:
https://guides.github.com/features/mastering-markdown/
• Cheat sheet:
https://guides.github.com/pdfs/markdown-cheatsheet-online.pdf
11 / 11