SlideShare une entreprise Scribd logo
1  sur  40
Télécharger pour lire hors ligne
Get IT right
Git Essentials
Bartosz Majsak (@majson), Thomas Hug (@gizmoo360)

http://ctp.com
http://github.com/ctpconsulting
1

© 2013 Cambridge Technology Partners
Copyright © 2013 Cambridge Technology Partners All Rights Reserved. Cambridge, its logo, and Get IT Right are trademarks of Cambridge Technology Partners.
About Us


Bartosz Majsak
 Java

Developer by day
 Open source junkie by night (Arquillian core team member)
 Conference speaker by passion (Devoxx, Jazoon ...)



Thomas Hug
 With

Cambridge Technology Partners since 2002
 Java Developer, TTL, Solution Architect
 Apache Committer, OSS contributor and aficionado

2

© 2013 Cambridge Technology Partners

10/25/2013
Why do we recommend Linux?

3

© 2013 Cambridge Technology Partners

10/25/2013
Git a British slang term meaning a contemptible
person, a bastard.

4

© 2013 Cambridge Technology Partners

10/25/2013
Git History



VCS of Linux Kernel



5

Founded 2005 as a replacement of BitKeeper

…not just Linux anymore

© 2013 Cambridge Technology Partners

10/25/2013
Git Concepts



Performance and Efficiency



6

No Central Server – Distributed VCS

Robustness

© 2013 Cambridge Technology Partners

10/25/2013
Disclaimer

when we say repository we actually
mean local repository (no network connectivity)

7

© 2013 Cambridge Technology Partners

10/25/2013
Installing and Configuring Git

© 2013 Cambridge Technology Partners
Installation





msysgit
cygwin
Atlassian SourceTree



XCode
Homebrew
MacPorts



Package Manager




9

© 2013 Cambridge Technology Partners

10/25/2013
Command line essentials

Playground
Objectives: getting familiar with essential commands and making your life easier












10

touch
cat / less
mkdir
ls
tree
cp / rm / mv
nano
history / ctrl+shift+r

© 2013 Cambridge Technology Partners

10/25/2013
User Identity



Your contact details

$ git config --global user.name “Bruce Wayne”
$ git config --global user.email “batman@gotham.com”
$ less ~/.gitconfig


SSH Key generation

$ ssh-keygen -t *dsa -C batman@gotham.com
*Using SHA-2 underneath. Approved by NSA
11

© 2013 Cambridge Technology Partners

10/25/2013
Presets


Color output

$ git config --global color.ui auto


Aliases. Useful for stuff impossible to remember…

$ git config --global alias.showlog "log --color -graph --pretty=format:'%Cred%h%Creset %C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold
blue)<%an>%Creset' --abbrev-commit"
Three levels of configuration:
--local (default, per repo) --global (per user) --system (machine)
10/25/2013
12

© 2013 Cambridge Technology Partners
Reference Material


Git References
 http://git-scm.com/

- official Git Home
 http://git-scm.com/book - Pro Git (Apress) online version
 http://git-scm.com/docs - Reference Documentation
 https://www.atlassian.com/git/tutorial - Git Tutorial
 http://gitready.com/ - Git Tutorial



Workflows
 https://www.atlassian.com/git/workflows

- Tutorial on common Git workflows
 http://yakiloo.com/getting-started-git-flow/ - About Git Flow (advanced topic)


Getting Help
 http://stackoverflow.com/

- All things programming
 https://help.github.com/ - Git Recipies

13

© 2013 Cambridge Technology Partners

10/25/2013
First Repository

© 2013 Cambridge Technology Partners
Creating a Repository
$
$
$
$

mkdir myrepo
cd myrepo
git init
git ls -la

git init

Do this in one swoop with
$ git init myrepo

15

© 2013 Cambridge Technology Partners

10/25/2013
Adding Files
$
$
$
$

touch index.html
git status
git add index.html
git status

git status
git add

git add works also with patterns:
$ git add ‘*.java’
$ git add .
$ git add folder/
You can even stage parts of a file
$ git add –p|-i
Stage all changes (including deleted files) in the working directory with
$ git add -A .
16

© 2013 Cambridge Technology Partners

10/25/2013
Committing Files
$ git commit
git commit
$ git status
$ git log --oneline --decorate

Commit directly with commit message:
$ git commit -m ‘Been there, done that’
$ git commit -am ‘Add also modified files directly’

Need a different commit editor?
export EDITOR=vim
17

© 2013 Cambridge Technology Partners
Three Stage Thinking

add
commit
checkout

Working
Directory
18

Staging
Area
© 2013 Cambridge Technology Partners

Repository
History
10/25/2013
Deleting and ignoring Files
$
$
$
$
$
$
$

touch test1.log test2.log
git add test1.log
git commit
vim .gitignore
git status
git rm test1.log
git commit

A shell script for easily accessing - gitignore boilerplates
https://github.com/simonwhitaker/gitignore-boilerplates

$ gibo Java Eclipse >> .gitignore
19

© 2013 Cambridge Technology Partners

.gitignore
git rm
How does my repo look like?
git log gives you and overview of your repository
structure.
$ git log
$ git log -p
$ git log --oneline --decorate
$ git log --graph --pretty=format:'%Cred%h%Creset
-%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold
blue)<%an>%Creset' --abbrev-commit

20

© 2013 Cambridge Technology Partners

10/25/2013
The Git File Workflow

ignore

add
edit

add
commit

rm
ignored

21

untracked

unmodified

© 2013 Cambridge Technology Partners

modified

staged

10/25/2013
Branching and Merging

© 2013 Cambridge Technology Partners
Branching
$ git branch mybranch
$ git branch
$ git checkout mybranch
Delete the branch with
$ git branch -d mybranch
$ git branch -D mybranch

Create a branch and check it out in one swoop
$ git checkout -b mybranch

23

© 2013 Cambridge Technology Partners

git branch

# if unmerged
Time for some serious work
Objectives: Getting familiar with branching and tagging.





Create new branch and modify repository
Switch between branches
Delete branch
Tag commits

$ git branch
$ git checkout
$ git tag

24

© 2013 Cambridge Technology Partners

10/25/2013
I’m not done yet
$
$
$
…
$
$
$

git status
git stash
git status

# staged stuff

git stash list
git stash apply [--index]
git stash drop stash@{0}

Apply and remove stash in one swoop
$ git stash pop

25

© 2013 Cambridge Technology Partners

git stash
Merging
checkout master
branch mybranch
showlog
branch

Feature

Fast-forward is default
$ git merge --no-ff

git merge

Feature

git
git
git
git

Feature

$
$
$
$

Deactivating fast-forward merges per branch
$ git config branch.master.mergeoptions

26

© 2013 Cambridge Technology Partners

"--no-ff"
Diffs
$ git diff mybranch master

git diff

Diff works also on the branch history
$ git diff
# unstaged
$ git diff HEAD^^ HEAD
# from to
$ git diff hash1...hash2 # from to

27

© 2013 Cambridge Technology Partners
Rebasing
$ git checkout master
$ git rebase mybranch

Rewriting history: Interactive rebase last four commits
$ git rebase --i HEAD~4

28

© 2013 Cambridge Technology Partners

git rebase
All your base are belong to us
Objectives: Learn how rebase works.


Make changes on selected branch and rebase it with
master

$ git rebase <BRANCH>

29

© 2013 Cambridge Technology Partners

10/25/2013
Going Remote

© 2013 Cambridge Technology Partners
Cloning Repositories
$ git clone [#remote]

Clone into a specific or existing (empty) folder
$ git clone [#remote] myclonedrepo

31

© 2013 Cambridge Technology Partners

git clone
Git Protocols


ssh / git: Securely connect to remote machines
git clone git@github.com:ctpconsulting/jazoon-git-workshops.git



HTTPS: Firewall friendly
git clone https://github.com/ctpconsulting/jazoon-git-workshops.git



File – simple. Can be used with e.g. a shared drive
git clone file:///home/thug/repo/chopen-workshop-git

Cloning directly without the file protocol will use hard links
$ git clone /home/thug/repo/jazoon-git-workshops

32

© 2013 Cambridge Technology Partners

10/25/2013
Remotes
$
$
$
$
$

git init myremoterepo
git remote
cd myremoterepo
… # commit something
git remote add origin [#remote]
git remote -v

Git is distributed – you can have more than one remote!
$ git remote add https-origin https://myrepo.com/repo.git

33

© 2013 Cambridge Technology Partners
Submitting Changes
$ git push -u origin master
$ …
$ git push
Forced push
$ git push --force

By default, Git always tries to push all matching branches.
Configuration to push only current to upstream:

$ git config push.default upstream

34

© 2013 Cambridge Technology Partners

git push
Retrieving Changes
$ git fetch
$ git merge origin/master

git fetch
git pull

Or short-hand
$ git pull

Resolution strategy for merge conflicts
$ git pull -Xours
$ git pull -Xtheirs

35

© 2013 Cambridge Technology Partners
Retrieving Changes
$ git pull --rebase
During a regular daily workflow where several team
members sync a single branch often, the timeline gets
polluted with unnecessary micro-merges on a regular
git pull. Rebasing ensures that the commits are
always re-applied so that the history stays linear.

Make git pull on master always use rebase
$ git config branch.master.rebase true
Or make it a default for every tracking branch strategy
$ git config --global branch.autosetuprebase always
36

© 2013 Cambridge Technology Partners
37

© 2013 Cambridge Technology Partners
38

© 2013 Cambridge Technology Partners
Get IT right
Thank you!

39

© 2013 Cambridge Technology Partners
Credits


40

Icons provided by Icons8: http://icons8.com/

© 2013 Cambridge Technology Partners

10/25/2013

Contenu connexe

Similaire à JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials

That's (g)it! par Sébastien Dawans CETIC
That's (g)it! par Sébastien Dawans CETICThat's (g)it! par Sébastien Dawans CETIC
That's (g)it! par Sébastien Dawans CETICLa FeWeb
 
Nyc Code Camp 2010 Git And Github
Nyc Code Camp 2010 Git And GithubNyc Code Camp 2010 Git And Github
Nyc Code Camp 2010 Git And Githubjptoto
 
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCDKubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCDSunnyvale
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An IntroductionBehzad Altaf
 
Git from the trenches
Git from the trenchesGit from the trenches
Git from the trenchesNuno Caneco
 
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808Cisco DevNet
 
Why Git Sucks and you'll use it anyways
Why Git Sucks and you'll use it anywaysWhy Git Sucks and you'll use it anyways
Why Git Sucks and you'll use it anywaysCarlos Taborda
 
ITCamp 2013 - Alessandro Pilotti - Git crash course for Visual Studio devs
ITCamp 2013 - Alessandro Pilotti - Git crash course for Visual Studio devsITCamp 2013 - Alessandro Pilotti - Git crash course for Visual Studio devs
ITCamp 2013 - Alessandro Pilotti - Git crash course for Visual Studio devsITCamp
 
Git - Boost Your DEV Team Speed and Productivity
Git - Boost Your DEV Team Speed and ProductivityGit - Boost Your DEV Team Speed and Productivity
Git - Boost Your DEV Team Speed and ProductivityKMS Technology
 
Development with Git and Gerrit - Eclipse DemoCamp Stuttgart - 2010-11-23
Development with Git and Gerrit - Eclipse DemoCamp Stuttgart - 2010-11-23Development with Git and Gerrit - Eclipse DemoCamp Stuttgart - 2010-11-23
Development with Git and Gerrit - Eclipse DemoCamp Stuttgart - 2010-11-23msohn
 
Intro to Git Devnet-1080 Cisco Live 2018
Intro to Git Devnet-1080 Cisco Live 2018Intro to Git Devnet-1080 Cisco Live 2018
Intro to Git Devnet-1080 Cisco Live 2018Ashley Roach
 
Git single branch
Git single branchGit single branch
Git single branchCarl Brown
 
maksym vlasov - culture of git as roots of your ci
maksym vlasov - culture of git as roots of your cimaksym vlasov - culture of git as roots of your ci
maksym vlasov - culture of git as roots of your ciDariia Seimova
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in UnityRifauddin Tsalitsy
 

Similaire à JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials (20)

Tech thursdays / GIT
Tech thursdays / GITTech thursdays / GIT
Tech thursdays / GIT
 
That's (g)it! par Sébastien Dawans CETIC
That's (g)it! par Sébastien Dawans CETICThat's (g)it! par Sébastien Dawans CETIC
That's (g)it! par Sébastien Dawans CETIC
 
Nyc Code Camp 2010 Git And Github
Nyc Code Camp 2010 Git And GithubNyc Code Camp 2010 Git And Github
Nyc Code Camp 2010 Git And Github
 
Geek git
Geek gitGeek git
Geek git
 
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCDKubernetes GitOps featuring GitHub, Kustomize and ArgoCD
Kubernetes GitOps featuring GitHub, Kustomize and ArgoCD
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Git from the trenches
Git from the trenchesGit from the trenches
Git from the trenches
 
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808
 
Why Git Sucks and you'll use it anyways
Why Git Sucks and you'll use it anywaysWhy Git Sucks and you'll use it anyways
Why Git Sucks and you'll use it anyways
 
ITCamp 2013 - Alessandro Pilotti - Git crash course for Visual Studio devs
ITCamp 2013 - Alessandro Pilotti - Git crash course for Visual Studio devsITCamp 2013 - Alessandro Pilotti - Git crash course for Visual Studio devs
ITCamp 2013 - Alessandro Pilotti - Git crash course for Visual Studio devs
 
Git - Boost Your DEV Team Speed and Productivity
Git - Boost Your DEV Team Speed and ProductivityGit - Boost Your DEV Team Speed and Productivity
Git - Boost Your DEV Team Speed and Productivity
 
Development with Git and Gerrit - Eclipse DemoCamp Stuttgart - 2010-11-23
Development with Git and Gerrit - Eclipse DemoCamp Stuttgart - 2010-11-23Development with Git and Gerrit - Eclipse DemoCamp Stuttgart - 2010-11-23
Development with Git and Gerrit - Eclipse DemoCamp Stuttgart - 2010-11-23
 
Intro to Git Devnet-1080 Cisco Live 2018
Intro to Git Devnet-1080 Cisco Live 2018Intro to Git Devnet-1080 Cisco Live 2018
Intro to Git Devnet-1080 Cisco Live 2018
 
GIT from n00b
GIT from n00bGIT from n00b
GIT from n00b
 
Git single branch
Git single branchGit single branch
Git single branch
 
maksym vlasov - culture of git as roots of your ci
maksym vlasov - culture of git as roots of your cimaksym vlasov - culture of git as roots of your ci
maksym vlasov - culture of git as roots of your ci
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in Unity
 
Intro. to Git and Github
Intro. to Git and GithubIntro. to Git and Github
Intro. to Git and Github
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
 
Git ongithub
Git ongithubGit ongithub
Git ongithub
 

Plus de jazoon13

JAZOON'13 - Joe Justice - Test First Saves The World
JAZOON'13 - Joe Justice - Test First Saves The WorldJAZOON'13 - Joe Justice - Test First Saves The World
JAZOON'13 - Joe Justice - Test First Saves The Worldjazoon13
 
JAZOON'13 - Ulrika Park- User Story telling The Lost Art of User Stories
JAZOON'13 - Ulrika Park- User Story telling The Lost Art of User StoriesJAZOON'13 - Ulrika Park- User Story telling The Lost Art of User Stories
JAZOON'13 - Ulrika Park- User Story telling The Lost Art of User Storiesjazoon13
 
JAZOON'13 - Oliver Zeigermann - Typed JavaScript with TypeScript
JAZOON'13 - Oliver Zeigermann - Typed JavaScript with TypeScriptJAZOON'13 - Oliver Zeigermann - Typed JavaScript with TypeScript
JAZOON'13 - Oliver Zeigermann - Typed JavaScript with TypeScriptjazoon13
 
JAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone before
JAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone beforeJAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone before
JAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone beforejazoon13
 
JAZOON'13 - Andres Almiray - Rocket Propelled Java
JAZOON'13 - Andres Almiray - Rocket Propelled JavaJAZOON'13 - Andres Almiray - Rocket Propelled Java
JAZOON'13 - Andres Almiray - Rocket Propelled Javajazoon13
 
JAZOON'13 - Sven Peters - How to do Kick-Ass Software Development
JAZOON'13 - Sven Peters - How to do Kick-Ass Software DevelopmentJAZOON'13 - Sven Peters - How to do Kick-Ass Software Development
JAZOON'13 - Sven Peters - How to do Kick-Ass Software Developmentjazoon13
 
JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...
JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...
JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...jazoon13
 
JAZOON'13 - Pawel Wrzeszcz - Visibility Shift In Distributed Teams
JAZOON'13 - Pawel Wrzeszcz - Visibility Shift In Distributed TeamsJAZOON'13 - Pawel Wrzeszcz - Visibility Shift In Distributed Teams
JAZOON'13 - Pawel Wrzeszcz - Visibility Shift In Distributed Teamsjazoon13
 
JAZOON'13 - Kai Waehner - Hadoop Integration
JAZOON'13 - Kai Waehner - Hadoop IntegrationJAZOON'13 - Kai Waehner - Hadoop Integration
JAZOON'13 - Kai Waehner - Hadoop Integrationjazoon13
 
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generation
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next GenerationJAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generation
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generationjazoon13
 
JAZOON'13 - Guide Schmutz - Kafka and Strom Event Processing In Realtime
JAZOON'13 - Guide Schmutz - Kafka and Strom Event Processing In RealtimeJAZOON'13 - Guide Schmutz - Kafka and Strom Event Processing In Realtime
JAZOON'13 - Guide Schmutz - Kafka and Strom Event Processing In Realtimejazoon13
 
JAZOON'13 - Andrej Vckovski - Go synchronized
JAZOON'13 - Andrej Vckovski - Go synchronizedJAZOON'13 - Andrej Vckovski - Go synchronized
JAZOON'13 - Andrej Vckovski - Go synchronizedjazoon13
 
JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experience
JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experienceJAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experience
JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experiencejazoon13
 
JAZOON'13 - Anatole Tresch - Go for the money (JSR 354) !
JAZOON'13 - Anatole Tresch - Go for the money (JSR 354) !JAZOON'13 - Anatole Tresch - Go for the money (JSR 354) !
JAZOON'13 - Anatole Tresch - Go for the money (JSR 354) !jazoon13
 
JAZOON'13 - Abdelmonaim Remani - The Economies of Scaling Software
JAZOON'13 - Abdelmonaim Remani - The Economies of Scaling SoftwareJAZOON'13 - Abdelmonaim Remani - The Economies of Scaling Software
JAZOON'13 - Abdelmonaim Remani - The Economies of Scaling Softwarejazoon13
 
JAZOON'13 - Stefan Saasen - True Git: The Great Migration
JAZOON'13 - Stefan Saasen - True Git: The Great MigrationJAZOON'13 - Stefan Saasen - True Git: The Great Migration
JAZOON'13 - Stefan Saasen - True Git: The Great Migrationjazoon13
 
JAZOON'13 - Stefan Saasen - Real World Git Workflows
JAZOON'13 - Stefan Saasen - Real World Git WorkflowsJAZOON'13 - Stefan Saasen - Real World Git Workflows
JAZOON'13 - Stefan Saasen - Real World Git Workflowsjazoon13
 

Plus de jazoon13 (17)

JAZOON'13 - Joe Justice - Test First Saves The World
JAZOON'13 - Joe Justice - Test First Saves The WorldJAZOON'13 - Joe Justice - Test First Saves The World
JAZOON'13 - Joe Justice - Test First Saves The World
 
JAZOON'13 - Ulrika Park- User Story telling The Lost Art of User Stories
JAZOON'13 - Ulrika Park- User Story telling The Lost Art of User StoriesJAZOON'13 - Ulrika Park- User Story telling The Lost Art of User Stories
JAZOON'13 - Ulrika Park- User Story telling The Lost Art of User Stories
 
JAZOON'13 - Oliver Zeigermann - Typed JavaScript with TypeScript
JAZOON'13 - Oliver Zeigermann - Typed JavaScript with TypeScriptJAZOON'13 - Oliver Zeigermann - Typed JavaScript with TypeScript
JAZOON'13 - Oliver Zeigermann - Typed JavaScript with TypeScript
 
JAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone before
JAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone beforeJAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone before
JAZOON'13 - Andres Almiray - Spock: boldly go where no test has gone before
 
JAZOON'13 - Andres Almiray - Rocket Propelled Java
JAZOON'13 - Andres Almiray - Rocket Propelled JavaJAZOON'13 - Andres Almiray - Rocket Propelled Java
JAZOON'13 - Andres Almiray - Rocket Propelled Java
 
JAZOON'13 - Sven Peters - How to do Kick-Ass Software Development
JAZOON'13 - Sven Peters - How to do Kick-Ass Software DevelopmentJAZOON'13 - Sven Peters - How to do Kick-Ass Software Development
JAZOON'13 - Sven Peters - How to do Kick-Ass Software Development
 
JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...
JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...
JAZOON'13 - Nikita Salnikov-Tarnovski - Multiplatform Java application develo...
 
JAZOON'13 - Pawel Wrzeszcz - Visibility Shift In Distributed Teams
JAZOON'13 - Pawel Wrzeszcz - Visibility Shift In Distributed TeamsJAZOON'13 - Pawel Wrzeszcz - Visibility Shift In Distributed Teams
JAZOON'13 - Pawel Wrzeszcz - Visibility Shift In Distributed Teams
 
JAZOON'13 - Kai Waehner - Hadoop Integration
JAZOON'13 - Kai Waehner - Hadoop IntegrationJAZOON'13 - Kai Waehner - Hadoop Integration
JAZOON'13 - Kai Waehner - Hadoop Integration
 
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generation
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next GenerationJAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generation
JAZOON'13 - Sam Brannen - Spring Framework 4.0 - The Next Generation
 
JAZOON'13 - Guide Schmutz - Kafka and Strom Event Processing In Realtime
JAZOON'13 - Guide Schmutz - Kafka and Strom Event Processing In RealtimeJAZOON'13 - Guide Schmutz - Kafka and Strom Event Processing In Realtime
JAZOON'13 - Guide Schmutz - Kafka and Strom Event Processing In Realtime
 
JAZOON'13 - Andrej Vckovski - Go synchronized
JAZOON'13 - Andrej Vckovski - Go synchronizedJAZOON'13 - Andrej Vckovski - Go synchronized
JAZOON'13 - Andrej Vckovski - Go synchronized
 
JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experience
JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experienceJAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experience
JAZOON'13 - Paul Brauner - A backend developer meets the web: my Dart experience
 
JAZOON'13 - Anatole Tresch - Go for the money (JSR 354) !
JAZOON'13 - Anatole Tresch - Go for the money (JSR 354) !JAZOON'13 - Anatole Tresch - Go for the money (JSR 354) !
JAZOON'13 - Anatole Tresch - Go for the money (JSR 354) !
 
JAZOON'13 - Abdelmonaim Remani - The Economies of Scaling Software
JAZOON'13 - Abdelmonaim Remani - The Economies of Scaling SoftwareJAZOON'13 - Abdelmonaim Remani - The Economies of Scaling Software
JAZOON'13 - Abdelmonaim Remani - The Economies of Scaling Software
 
JAZOON'13 - Stefan Saasen - True Git: The Great Migration
JAZOON'13 - Stefan Saasen - True Git: The Great MigrationJAZOON'13 - Stefan Saasen - True Git: The Great Migration
JAZOON'13 - Stefan Saasen - True Git: The Great Migration
 
JAZOON'13 - Stefan Saasen - Real World Git Workflows
JAZOON'13 - Stefan Saasen - Real World Git WorkflowsJAZOON'13 - Stefan Saasen - Real World Git Workflows
JAZOON'13 - Stefan Saasen - Real World Git Workflows
 

Dernier

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 

Dernier (20)

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 

JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials

  • 1. Get IT right Git Essentials Bartosz Majsak (@majson), Thomas Hug (@gizmoo360) http://ctp.com http://github.com/ctpconsulting 1 © 2013 Cambridge Technology Partners Copyright © 2013 Cambridge Technology Partners All Rights Reserved. Cambridge, its logo, and Get IT Right are trademarks of Cambridge Technology Partners.
  • 2. About Us  Bartosz Majsak  Java Developer by day  Open source junkie by night (Arquillian core team member)  Conference speaker by passion (Devoxx, Jazoon ...)  Thomas Hug  With Cambridge Technology Partners since 2002  Java Developer, TTL, Solution Architect  Apache Committer, OSS contributor and aficionado 2 © 2013 Cambridge Technology Partners 10/25/2013
  • 3. Why do we recommend Linux? 3 © 2013 Cambridge Technology Partners 10/25/2013
  • 4. Git a British slang term meaning a contemptible person, a bastard. 4 © 2013 Cambridge Technology Partners 10/25/2013
  • 5. Git History   VCS of Linux Kernel  5 Founded 2005 as a replacement of BitKeeper …not just Linux anymore © 2013 Cambridge Technology Partners 10/25/2013
  • 6. Git Concepts   Performance and Efficiency  6 No Central Server – Distributed VCS Robustness © 2013 Cambridge Technology Partners 10/25/2013
  • 7. Disclaimer when we say repository we actually mean local repository (no network connectivity) 7 © 2013 Cambridge Technology Partners 10/25/2013
  • 8. Installing and Configuring Git © 2013 Cambridge Technology Partners
  • 10. Command line essentials Playground Objectives: getting familiar with essential commands and making your life easier         10 touch cat / less mkdir ls tree cp / rm / mv nano history / ctrl+shift+r © 2013 Cambridge Technology Partners 10/25/2013
  • 11. User Identity  Your contact details $ git config --global user.name “Bruce Wayne” $ git config --global user.email “batman@gotham.com” $ less ~/.gitconfig  SSH Key generation $ ssh-keygen -t *dsa -C batman@gotham.com *Using SHA-2 underneath. Approved by NSA 11 © 2013 Cambridge Technology Partners 10/25/2013
  • 12. Presets  Color output $ git config --global color.ui auto  Aliases. Useful for stuff impossible to remember… $ git config --global alias.showlog "log --color -graph --pretty=format:'%Cred%h%Creset %C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" Three levels of configuration: --local (default, per repo) --global (per user) --system (machine) 10/25/2013 12 © 2013 Cambridge Technology Partners
  • 13. Reference Material  Git References  http://git-scm.com/ - official Git Home  http://git-scm.com/book - Pro Git (Apress) online version  http://git-scm.com/docs - Reference Documentation  https://www.atlassian.com/git/tutorial - Git Tutorial  http://gitready.com/ - Git Tutorial  Workflows  https://www.atlassian.com/git/workflows - Tutorial on common Git workflows  http://yakiloo.com/getting-started-git-flow/ - About Git Flow (advanced topic)  Getting Help  http://stackoverflow.com/ - All things programming  https://help.github.com/ - Git Recipies 13 © 2013 Cambridge Technology Partners 10/25/2013
  • 14. First Repository © 2013 Cambridge Technology Partners
  • 15. Creating a Repository $ $ $ $ mkdir myrepo cd myrepo git init git ls -la git init Do this in one swoop with $ git init myrepo 15 © 2013 Cambridge Technology Partners 10/25/2013
  • 16. Adding Files $ $ $ $ touch index.html git status git add index.html git status git status git add git add works also with patterns: $ git add ‘*.java’ $ git add . $ git add folder/ You can even stage parts of a file $ git add –p|-i Stage all changes (including deleted files) in the working directory with $ git add -A . 16 © 2013 Cambridge Technology Partners 10/25/2013
  • 17. Committing Files $ git commit git commit $ git status $ git log --oneline --decorate Commit directly with commit message: $ git commit -m ‘Been there, done that’ $ git commit -am ‘Add also modified files directly’ Need a different commit editor? export EDITOR=vim 17 © 2013 Cambridge Technology Partners
  • 18. Three Stage Thinking add commit checkout Working Directory 18 Staging Area © 2013 Cambridge Technology Partners Repository History 10/25/2013
  • 19. Deleting and ignoring Files $ $ $ $ $ $ $ touch test1.log test2.log git add test1.log git commit vim .gitignore git status git rm test1.log git commit A shell script for easily accessing - gitignore boilerplates https://github.com/simonwhitaker/gitignore-boilerplates $ gibo Java Eclipse >> .gitignore 19 © 2013 Cambridge Technology Partners .gitignore git rm
  • 20. How does my repo look like? git log gives you and overview of your repository structure. $ git log $ git log -p $ git log --oneline --decorate $ git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit 20 © 2013 Cambridge Technology Partners 10/25/2013
  • 21. The Git File Workflow ignore add edit add commit rm ignored 21 untracked unmodified © 2013 Cambridge Technology Partners modified staged 10/25/2013
  • 22. Branching and Merging © 2013 Cambridge Technology Partners
  • 23. Branching $ git branch mybranch $ git branch $ git checkout mybranch Delete the branch with $ git branch -d mybranch $ git branch -D mybranch Create a branch and check it out in one swoop $ git checkout -b mybranch 23 © 2013 Cambridge Technology Partners git branch # if unmerged
  • 24. Time for some serious work Objectives: Getting familiar with branching and tagging.     Create new branch and modify repository Switch between branches Delete branch Tag commits $ git branch $ git checkout $ git tag 24 © 2013 Cambridge Technology Partners 10/25/2013
  • 25. I’m not done yet $ $ $ … $ $ $ git status git stash git status # staged stuff git stash list git stash apply [--index] git stash drop stash@{0} Apply and remove stash in one swoop $ git stash pop 25 © 2013 Cambridge Technology Partners git stash
  • 26. Merging checkout master branch mybranch showlog branch Feature Fast-forward is default $ git merge --no-ff git merge Feature git git git git Feature $ $ $ $ Deactivating fast-forward merges per branch $ git config branch.master.mergeoptions 26 © 2013 Cambridge Technology Partners "--no-ff"
  • 27. Diffs $ git diff mybranch master git diff Diff works also on the branch history $ git diff # unstaged $ git diff HEAD^^ HEAD # from to $ git diff hash1...hash2 # from to 27 © 2013 Cambridge Technology Partners
  • 28. Rebasing $ git checkout master $ git rebase mybranch Rewriting history: Interactive rebase last four commits $ git rebase --i HEAD~4 28 © 2013 Cambridge Technology Partners git rebase
  • 29. All your base are belong to us Objectives: Learn how rebase works.  Make changes on selected branch and rebase it with master $ git rebase <BRANCH> 29 © 2013 Cambridge Technology Partners 10/25/2013
  • 30. Going Remote © 2013 Cambridge Technology Partners
  • 31. Cloning Repositories $ git clone [#remote] Clone into a specific or existing (empty) folder $ git clone [#remote] myclonedrepo 31 © 2013 Cambridge Technology Partners git clone
  • 32. Git Protocols  ssh / git: Securely connect to remote machines git clone git@github.com:ctpconsulting/jazoon-git-workshops.git  HTTPS: Firewall friendly git clone https://github.com/ctpconsulting/jazoon-git-workshops.git  File – simple. Can be used with e.g. a shared drive git clone file:///home/thug/repo/chopen-workshop-git Cloning directly without the file protocol will use hard links $ git clone /home/thug/repo/jazoon-git-workshops 32 © 2013 Cambridge Technology Partners 10/25/2013
  • 33. Remotes $ $ $ $ $ git init myremoterepo git remote cd myremoterepo … # commit something git remote add origin [#remote] git remote -v Git is distributed – you can have more than one remote! $ git remote add https-origin https://myrepo.com/repo.git 33 © 2013 Cambridge Technology Partners
  • 34. Submitting Changes $ git push -u origin master $ … $ git push Forced push $ git push --force By default, Git always tries to push all matching branches. Configuration to push only current to upstream: $ git config push.default upstream 34 © 2013 Cambridge Technology Partners git push
  • 35. Retrieving Changes $ git fetch $ git merge origin/master git fetch git pull Or short-hand $ git pull Resolution strategy for merge conflicts $ git pull -Xours $ git pull -Xtheirs 35 © 2013 Cambridge Technology Partners
  • 36. Retrieving Changes $ git pull --rebase During a regular daily workflow where several team members sync a single branch often, the timeline gets polluted with unnecessary micro-merges on a regular git pull. Rebasing ensures that the commits are always re-applied so that the history stays linear. Make git pull on master always use rebase $ git config branch.master.rebase true Or make it a default for every tracking branch strategy $ git config --global branch.autosetuprebase always 36 © 2013 Cambridge Technology Partners
  • 37. 37 © 2013 Cambridge Technology Partners
  • 38. 38 © 2013 Cambridge Technology Partners
  • 39. Get IT right Thank you! 39 © 2013 Cambridge Technology Partners
  • 40. Credits  40 Icons provided by Icons8: http://icons8.com/ © 2013 Cambridge Technology Partners 10/25/2013