Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Workshop Git
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Martijn Brekhof
March 08, 2016
Programming
1
41
Workshop Git
Workshop Git for Thalia at Radboud University Nijmegen
Martijn Brekhof
March 08, 2016
Tweet
Share
Other Decks in Programming
See All in Programming
日本だけで解禁されているアプリ起動の方法
ryunakayama
0
330
なるべく楽してバックエンドに型をつけたい!(楽とは言ってない)
hibiki_cube
0
150
CSC307 Lecture 09
javiergs
PRO
1
840
CSC307 Lecture 07
javiergs
PRO
1
560
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
210
Rubyと楽しいをつくる / Creating joy with Ruby
chobishiba
0
150
Claude Codeと2つの巻き戻し戦略 / Two Rewind Strategies with Claude Code
fruitriin
0
160
CSC307 Lecture 08
javiergs
PRO
0
680
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
120
CSC307 Lecture 06
javiergs
PRO
0
690
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.3k
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
240
Featured
See All Featured
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
150
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
WCS-LA-2024
lcolladotor
0
450
Side Projects
sachag
455
43k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
350
Why Our Code Smells
bkeepers
PRO
340
58k
So, you think you're a good person
axbom
PRO
2
1.9k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
62
50k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
320
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
440
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
110
Rails Girls Zürich Keynote
gr2m
96
14k
Transcript
v2a – h01 – 1 Workshop Git • 2hour workshop
based on AT Computing's course: • Requirements: ◗ Computer with Git installed ◗ Basic knowledge of Linux/UNIX operating systems and commandline usage • License: AttributionNonCommercialNoDerivatives 4.0 International Version control with Git http://www.atcomputing.net/Training/versioncontrolwithgit.en.php © 2016 AT Computing http://creativecommons.org/licenses/byncnd/4.0/ (CC BYNCND 4.0)
v2a – h01 – 2 Different implementations (1) Client file1
Version Database file2 ... version 2 version 1 version 1 ... Server Client file1 file2 ... Client file1 file2 ... Client/Server Centralized Local Version Database version 2 version 1 version 1 ... © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 3 Different implementations (2) Server Client/Server
file1 file2 ... Client/Server file1 file2 ... Version Database version 2 version 1 version 1 ... Version Database version 2 version 1 version 1 ... Version Database version 2 version 1 version 1 ... Client/Server Decentralized • Optional: set up one repository as server only © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 4 History of git • September
30th 1998: Larry McVoy announces BitKeeper • 2002: decision is made to use BitKeeper for kernel development • April 2005: ◗ BitMover announced that it would stop providing a version of BitKeeper free of charge to the community ◗ Git development began as Linus Torvalds could not find any other that met his requirements • June 16th 2005: first kernel released using git (kernel 2.6.12) © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 5 Setting up a repository Command:
git init [options] [directory] • creates a new git repository • Examples: ◗ creating a new empty repository: ◗ Transforming an existing directory into a Git repository: $ git init my_app $ ls a my_app .git $ ls a my_app/.git branches config description HEAD hooks info objects refs $ cd my_old_app $ git init $ ls a README pingpong.c .git © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 6 Configure your Git environment Command:
git config [options] <variable> • configures your git installation • Stored in plaintext files ◗ per user (option global): .gitconfig in your homedir. ◗ per repository (option local) (default): <PROJECTDIR>/.git/config ◗ systemwide (option system): /etc/gitconfig • Examples ◗ Define the author name to be used for all commits ◗ Define the author email to be used for all commits $ git config global user.name “John Doe“ $ git config global user.email
[email protected]
© 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 7 Adding files file1 file2 ...
git repository version 1 version 1 ... file1 file2 ... git repository Current situation Versioned situation Command: git add [options] <file|directory>... • add files to the staging area • Example: add a single file $ git add file1 file2 ... file1 file2 ... git repository file1 file2 ... Staged git add git commit © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 8 Committing the staged snapshot file1
file2 ... git repository version 1 version 1 ... file1 file2 ... git repository Current situation Versioned situation Command: git commit [options] [file]... • commit the staged snapshot • Example: $ git commit m "Initial commit" file1 file2 ... git repository file1 file2 ... Staged git add git commit © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 9 Lifecycle of file status Files
can be in one of the following four states Untracked Unmodified Modified Staged Add the file Edit the file Add the file Remove the file Commit © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 10 How Git stores versions 1a5c986b
ca85f079 753c4b26 compressed data compressed data compressed data 100644 blob 1a5c986b .gitignore 100644 blob ca85f079 Makefile 100644 blob 753c4b26 README 040000 tree 264626fa inc 040000 tree a2b93a56 snd 040000 tree bc4c62b7 src 100644 blob c3031628 ... 264626fa 100644 blob 70176522 ... 100644 blob 5c82d8e6 ... a2b93a56 100644 blob dcb49d7c ... 100644 blob c5a9c379 ... bc4c62b7 Tree object Blobs tree 753c4b26 parent 81f92422 author martijn <martijn... committer martijn <mart... Updated versionnumber Commit object 5a4eebb6 753c4b26 © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 11 Visualising the git commit history
• Each commit object contains a reference to the previous commit (except the first commit) ◗ Because of this visuals of a git history seems to go backwards ◗ HEAD points to last commit object ◗ master is a branch (more on that later) a38f278 3f5e909 81f9242 5a4eebb HEAD oldest newest master © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 12 Creating a branch Command: git
branch <name> [<commit/tag/branchname>] • List, create, or delete branches • Examples: ◗ Create a new branch from HEAD ◗ Create a new branch from a specific commit 2600f97 HEAD master $ git branch features/explbats features/explbats $ git branch customers/atc 81f9242 81f9242 customers/atc 81f9242 2600f97 HEAD master features/explbats © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 13 Merging a branch Command: git
merge <branchname> • Join two or more development histories together • Example: ◗ Merge customers/atc on master $ git checkout master Switched to branch 'master' ... $ git merge customers/atc Merge made by the 'recursive' strategy. src/engine.c | 4 ++++ src/main.c | 1 + 2 files changed, 5 insertions(+) 2600f97 HEAD master 81f9242 customers/atc 37f1803 2cc83bc • Performs a 3way merge • New commit has 2 parents 2600f97 master 81f9242 customers/atc 37f1803 HEAD after merge © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 14 Working together concurrently master ...
Jack/master master ... Anna/master master ... Jack/master master ... Jack/master $ git fetch Jack $ git merge Jack/master $ git fetch Anna master ... Jack/master Do not push, but pull updates in Anna Jack © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 15 Working together with many developers
Anna file1 file2 ... Version Database version 2 version 1 version 1 ... Jack file1 file2 ... Version Database version 2 version 1 version 1 ... Bob file1 file2 ... Version Database version 2 version 1 version 1 ... Alice file1 file2 ... Version Database version 2 version 1 version 1 ... © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 16 Problem with pushing updates master
... Jack/master master ... Anna/master $ git push Anna master master ... Jack/master • Anna's commit history updated without her knowledge $ git status On branch master nothing to commit, ... $ git status On branch master ... modified: README © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 17 Server Version Database version 2
version 1 version 1 ... Working with a central remote repository Jack's clone file1 file2 ... Version Database version 2 version 1 version 1 ... Anna's clone file1 file2 ... Version Database version 2 version 1 version 1 ... • Each developer fetches and pushes to the central server © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 18 Fastforward merge • Your master
branch • Remote's master branch • After you push remote's master branch 501f497 3c54c20 9a5ac52 6a59afb 501f497 HEAD master 6a59afb HEAD master HEAD master 501f497 3c54c20 9a5ac52 6a59afb © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 19 Working on remote branches •
Git does not allow you to work directly on remote branches. We therefore need to: 1. Create a new local branch 2. Connect local branch to a remote branch 3. Checkout local branch 4. Develop on local branch 5. Use push to update remote branch • Example • NOTE: Cloning automatically makes your local master track origin/master $ git branch bug/12 origin/bug/12 $ git checkout bug/12 … $ git commit $ git push © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 20 Centralized workflow • Uses a
single branch (usually master) • Rebase • Merge ... git clone git clone git push git pull rebase OR git pull master Central repository git push © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 21 bug/13 Longrunning branches: GitFlow develop
release0.9 feature/explodingbats master GitFlow model • Two long running main branches: Master and Develop • Arbitrary amount of support branches v0.1 v0.3 bug/12 v0.2 © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 22 Integrationmanager (forking) workflow • One
central repository serving the “official” project • Each developer has their own public repository • Only maintainer has push access to central repository • Developers ask maintainer to pull in their changes ... Central repository ... Anna's public repository ... Jack's public repository push push push pull pull Developer Developer Maintainer © 2016 AT Computing (CC BYNCND 4.0)
v2a – h01 – 23 Dictator and lieutenants workflow ...
Central repository ... Lieutenant Developer's public repository Lieutenant Dictator ... ... ... Developer's public repository Developer's public repository Developer's public repository © 2016 AT Computing (CC BYNCND 4.0)