git & egit beginner workshop.pdf
TRANSCRIPT
![Page 1: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/1.jpg)
Git & EGit beginner WorkshopLearn Git with Eclipse
EclipseCon France5 June 2013
Vincent LalanneIgor Laborie
Matthias Sohn
![Page 2: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/2.jpg)
The team
Igor Laborie Software Architect at AKKAGit enthusiast
Vincent LalanneSoftware Engineer at AKKA
Matthias Sohn Product Owner at SAP
![Page 3: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/3.jpg)
The Raspberry Pi
http://www.raspberrypi.org/http://elinux.org/RPi_Hub
Model A ~22 €Model B ~33 €
● ARM processor 700 Mhz● RAM: 512Mb ● HDMI, Composite● Ethernet● 2 USB port● SD Card● 26 Pins
![Page 4: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/4.jpg)
Prepare to exercices
RaspberryPi : PiGit / EclipseConOr get EGit-Workshop.zip from an USB stick=> Open index.html with a modern browser
You need an EGit version > v2.2.0=> Install Eclipse Java Juno SR2 if needed.
Exercises are also available at http://ilaborie.github.io/Git--EGit-beginner-workshop
![Page 5: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/5.jpg)
Agenda
● Introducing Git● Working locally● Branches● Remotes● Exam
○ => Win a RaspberryPi B !
![Page 6: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/6.jpg)
Introducing GitGit, JGit and EGit
![Page 7: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/7.jpg)
VCS
A Version Control System● record changes● retrieve a previous version● provide collaborative works
Like SVN, CVS, ClearCase, ...
![Page 8: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/8.jpg)
Central VCS Server
Version Database
CVCS
Computer A
File
Checkout
Computer B
File
Checkout
Version 3
Version 1
Version 2
![Page 9: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/9.jpg)
DVCSServer Computer
Version Database
Version 3
Version 1
Version 2
Computer B
Version Database
Version 3
Version 1
Version 2
File
Computer A
Version Database
Version 3
Version 1
Version 2
File
![Page 10: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/10.jpg)
Git
● easier offline usage● easier to fork and merge (branches)● speed● scalability● a lot of workflow● ...
Git is developer-friendly.Flexibility (with Workflow) is industry-friendly.
![Page 11: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/11.jpg)
JGit & EGit
JGit is a (partial) implementation of Git● lightweight,● pure Java library,● modular (OSGi-ready)
EGit is the Eclipse team provider for Git● implemented on top of JGit● Gerrit support● Github support
![Page 12: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/12.jpg)
Exercises 1 & 2
1 - Installation & Configuration● http://192.168.42.1/exo1.html● USB Stick: exo1.html● http://ilaborie.github.io/Git--EGit-beginner-
workshop/exo1.html
2 - Create Repositories● http://192.168.42.1/exo2.html● USB Stick: exo2.html● http://ilaborie.github.io/Git--EGit-beginner-
workshop/exo2.html
![Page 13: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/13.jpg)
Notes
● Hierarchical configuration level: ○ system
○ user
○ project
● Authentication with Private/Public SSH keys
![Page 14: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/14.jpg)
Working LocallyBasic operations
![Page 15: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/15.jpg)
Commit
A commit just stores modifications (version) into the repository (local).
Be careful, make significant commits to provide a beautiful history.
![Page 16: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/16.jpg)
The Staging Area / Index
● Intermediate zone between the working directory and the repository.
● Useful to prepare commit.● Can be skipped.
![Page 17: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/17.jpg)
File status into Git
● A file can beuntracked - not managed by the repositorytracked - managed by the repository
● A tracked file can beunmodified if = last commitmodified if ≠ staging areastaged if ≠ last commit & = staging area*
*
?
![Page 18: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/18.jpg)
Add
Working Directory
Staging Area Repository Never
Tracked Files
add**
?
![Page 19: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/19.jpg)
Remove
Working Directory
Staging Area RepositoryUntracked Files
remove
![Page 20: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/20.jpg)
Move
Working Directory
Staging Area Repository Never
Tracked Files
move
![Page 21: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/21.jpg)
Ignore
Working Directory
Staging Area Repository Never
Tracked Files
?ignore
![Page 22: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/22.jpg)
Commit
Working Directory
Staging Area Repository Never
Tracked Files
commit
*
![Page 23: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/23.jpg)
Exercices 3 & 4
3 - Basic Operations● http://192.168.42.1/exo3.html● USB Stick: exo3.html● http://ilaborie.github.io/Git--EGit-beginner-
workshop/exo3.html
4 - Playing with Diffs (optional)● http://192.168.42.1/exo4.html● USB Stick: exo4.html● http://ilaborie.github.io/Git--EGit-beginner-
workshop/exo4.html
![Page 24: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/24.jpg)
Notes
● It's easy to modify the last commit (amend)But Don't modify a shared commit !
● Reset allows you to unstage (and more)
![Page 25: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/25.jpg)
BranchesThe DAG
![Page 26: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/26.jpg)
Git Objects
sizeblobEclipse Public License
sizeblob<html><head> <title>Index
sizetreesizecommit
blob 5b1d3 README.md
blob 911e7 LICENSE
blob cba0a index.html
tree 92ec2
author Igor
committer Igor
parents ce23a1
First commit of my project
98ca9..92ec2..
sizeblobREADME===
5b1d3..
911e7..
cba0a..
sizecommit...
ce23a1..
![Page 27: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/27.jpg)
The Directed Acyclic Graph
c0 c1 c2 c3
c4 c5 c6
c7 c8 c9 c10
c11 c12
![Page 28: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/28.jpg)
Branches
c0 c1 c2 c3
c4 c5 c6
c7 c8 c9 c10
c11 c12
HEA
D
mas
ter
feat
ure_
A
feature_B
How many commits in feature A ?
mas
ter
![Page 29: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/29.jpg)
Create a new branch: feature_A
c0 c1 c2 c3
master
![Page 30: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/30.jpg)
Create a new branch: feature_A
c0 c1 c2 c3
master
feat
ure_
A
![Page 31: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/31.jpg)
Create a new branch: feature_A
c0 c1 c2 c3
master
feat
ure_
A
![Page 32: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/32.jpg)
Implementing the feature A
c0 c1 c2 c3
master
feat
ure_
A
![Page 33: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/33.jpg)
Implementing the feature A
c0 c1 c2 c3
master
c4fe
atur
e_A
![Page 34: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/34.jpg)
Implementing the feature A
c0 c1 c2 c3
master
c4 c5
feat
ure_
A
![Page 35: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/35.jpg)
Checkout to master
c0 c1 c2 c3
master
c4 c5
feat
ure_
A
![Page 36: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/36.jpg)
Checkout to master
c0 c1 c2 c3
master
c4 c5
feat
ure_
A
![Page 37: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/37.jpg)
Working on master
c0 c1 c2 c3
master
c4 c5
feat
ure_
A
![Page 38: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/38.jpg)
Working on master
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
master
![Page 39: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/39.jpg)
Working on master
c7
master
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
![Page 40: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/40.jpg)
Create a new branch: feature_B
c7
master
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
![Page 41: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/41.jpg)
Create a new branch: feature_B
c7
master
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
feature_B
![Page 42: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/42.jpg)
Implementing the feature B
c7
master
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
feature_B
![Page 43: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/43.jpg)
Implementing the feature B
c8feature_B
c7
master
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
![Page 44: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/44.jpg)
Implementing the feature B
c9
feature_B
c8c7
master
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
![Page 45: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/45.jpg)
Step back to master
c9
feature_B
c8c7
master
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
![Page 46: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/46.jpg)
Step back to master
c9
feature_B
c8c7
master
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
![Page 47: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/47.jpg)
Let's merge master with feature_A
c9
feature_B
c8c7
master
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
![Page 48: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/48.jpg)
Let's merge master with feature_A
c9
feature_B
c8
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
c10
mas
ter
c7
![Page 49: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/49.jpg)
Go to feature_B
c9
feature_B
c8
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
c10
mas
ter
c7
![Page 50: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/50.jpg)
Go to feature_B
c9
feature_B
c8
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
c10
mas
ter
c7
![Page 51: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/51.jpg)
Let's rebase on master
c9
feature_B
c8
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
c10
mas
ter
c7
![Page 52: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/52.jpg)
Let's rebase on master
c9
feature_B
c8
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
c10
mas
ter
c7
c8'
![Page 53: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/53.jpg)
Let's rebase on master
c9
feature_B
c8
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
c10
mas
ter
c7
c8' c9'
![Page 54: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/54.jpg)
Let's rebase on master
c9
feature_B
c8
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
c10
mas
ter
c7
c8' c9'
![Page 55: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/55.jpg)
Let's rebase on master
feature_B
c0 c1 c2 c3
c4 c5fe
atur
e_A
c6
c10
mas
ter
c7
c8' c9'
c8 c9
![Page 56: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/56.jpg)
Merge vs Rebase
feature_B
c0 c1 c2 c3
c4 c5
feat
ure_
A
c6
c10
mas
ter
c7
c8' c9'
c9
feature_B
c8
c0 c1 c2 c3
c4 c5
feat
ure_
A
c6
c10
mas
ter
c7 c11
![Page 57: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/57.jpg)
Exercices 5 & 6
5 - Branches Workflow● http://192.168.42.1/exo5.html● USB Stick: exo5.html● http://ilaborie.github.io/Git--EGit-beginner-
workshop/exo5.html
6 - Handle Conflicts (Optional)● http://192.168.42.1/exo6.html● USB Stick: exo6.html● http://ilaborie.github.io/Git--EGit-beginner-
workshop/exo6.html
![Page 58: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/58.jpg)
Notes
● Tag is a reference on a commit
● SHA-1 allow integrity check (fsck)
● Git rarely deletes data, reflog could save your life
![Page 59: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/59.jpg)
RemotesSharing
![Page 60: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/60.jpg)
Remotes
A remote repositories is defined by● an alias,● an URL
ssh://http://https://file://
git://
![Page 61: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/61.jpg)
Initially
Remote
mas
ter
c0
Local
![Page 62: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/62.jpg)
Clone
Remote Local
mas
ter
c0
ori
gin
/mas
ter
c0
master
![Page 63: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/63.jpg)
A Local Commit
Remote Local
mas
ter
c0
ori
gin
/mas
ter
c0
master
c1
![Page 64: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/64.jpg)
A Remote Commit
Remote Localm
aste
r
c0
ori
gin
/mas
ter
c0
master
c1c2
![Page 65: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/65.jpg)
Fetch
mas
ter
Remote
c0
ori
gin
/mas
ter
Local
c0
master
c1
c2
c2
![Page 66: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/66.jpg)
Pull
mas
ter
Remote
c0
Localm
aster
c2 c3
ori
gin
/mas
ter
c0
c1
c2
![Page 67: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/67.jpg)
Push
mas
ter
Remote
c0
Localm
aster
c3
ori
gin
/mas
ter
c0
c1
c2
c3
c1
c2
![Page 68: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/68.jpg)
Exercices 7 & 8
7 - Clone Repository ● http://192.168.42.1/exo7.html● USB Stick: exo7.html● http://ilaborie.github.io/Git--EGit-beginner-
workshop/exo7.html
8 - Remote Workflow● http://192.168.42.1/exo8.html● USB Stick: exo8.html● http://ilaborie.github.io/Git--EGit-beginner-
workshop/exo8.html
![Page 69: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/69.jpg)
Notes
● Blame show commit details for each line of a file (Annotation)
● Branch tracking
● Upstream
![Page 71: Git & EGit beginner Workshop.pdf](https://reader034.vdocuments.us/reader034/viewer/2022051200/5870b86c1a28ab676e8bdbfc/html5/thumbnails/71.jpg)
ThanksQuestion(s)