SlideShare une entreprise Scribd logo
1  sur  41
GIT

      By
Serhiy Yakovyn
Agenda
• Describe how GIT commands corresponds to
  SubVersioN ones.
• Provide some commonly used workflows.
• Explain how to use GIT when your team works
  with SVN.
• Give a quick overview of GIT internals
GIT to SVN mapping
Create the new repo:
svnadmin create repo
svn import file://repo

git init
git add .
git commit
GIT to SVN mapping
To revert:
svn revert path
Git checkout path
GIT to SVN mapping
To commit:
svn commit

git commit -a
GIT to SVN mapping
Branching:
svn copy http://example.com/svn/trunk
http://example.com/svn/branches/branch

svn switch http://example.com/svn/branches/branch

git branch branch
git checkout branch
GIT to SVN mapping
List:
svn list http://example.com/svn/branches/
git branch
GIT to SVN mapping
Moving between revisions:
svn update -r rev
svn update

git checkout rev
git checkout prevbranch
GIT to SVN mapping
(assuming the branch was created in revision 20
and you are inside a working copy of trunk)
svn merge -r 20:HEAD
http://example.com/svn/branches/branch

git merge branch
GIT to SVN mapping
Pick commit from another branch:
svn merge -c rev url
git cherry-pick rev
GIT to SVN mapping
Cloning remote repo:
svn checkout url

git clone url
GIT to SVN mapping
Remote branch:
svn switch url
git checkout --track -b branch origin/branch
GIT to SVN mapping
Remote update:
svn update
git pull
GIT to SVN mapping
Remote commit:
svn commit
git push
Some commonly used workflows
1. Write new features in feature branches.
2. Integrate on the master branch.
3. Deploy from the release branch.
Some commonly used workflows
1. Write new features in feature branches.
# create a new feature branch in the remote repo named feature_branch
git push origin master:refs/heads/feature_branch

# make sure we've got everything updated from the remote repo
git fetch origin

# create a local branch named feature_branch that tracks
# the remote feature_branch
git branch --track feature_branch origin/feature_branch

# check out the new branch
git checkout feature_branch
Some commonly used workflows
2. Integrate on master branch.
git merge master

git checkout master
git merge feature_branch

# this has to be in competition for one of the least intuitive
# commands ever, but it removes the remote branch
git push origin :refs/heads/feature_branch

# remove the local branch
git branch -d feature_branch
Some commonly used workflows
3. Deploy from the release branch.
# checkout the deploy branch
git checkout deploy

# pull the deploy branch, just to be sure everything's up to date
git pull origin deploy

# merge the master branch into the deploy branch
git merge master

# tag the release that we're about to make
git tag -a -m "My comments about this release" [tag_name]

# push it all up to the remote repository
git push --tags origin deploy

# switch back to the master branch,
# since we never do any work on the deploy branch
git checkout master
Some commonly used workflows
1. Pull to update your local master
2. Check out a feature branch
3. Do work in your feature branch, committing early
and often
4. Rebase frequently to incorporate upstream
changes
5. Interactive rebase (squash) your commits
6. Merge your changes with master
7. Push your changes to the upstream
Some commonly used workflows
1. Pull to update your local master
git checkout master
git pull origin master
Some commonly used workflows
2. Check out a branch
git checkout -b <branch>
Some commonly used workflows
3. Do work in your feature branch, committing
early and often
Hacking…
git commit
Hacking…
git commit
Hacking…
git commit
Some commonly used workflows
4. Rebase frequently to incorporate upstream
changes
git fetch origin master
git rebase origin/master
Or (longer way):
git checkout master
git pull
git checkout <branch>
git rebase master
Some commonly used workflows
5. Interactive rebase (squash) your commits
git rebase -i origin/master
Some commonly used workflows
6. Merge your changes with master
git checkout master
git pull
git merge <branch>
Some commonly used workflows
7. Push your changes to the upstream
git push origin master
GIT SVN

How to use GIT when your team works with
SVN?
1. Creating working copy? – no! working repo.
git svn init …
Some magic 
git svn fetch
Or (if you are lucky! – I’ve never been):
git svn clone …
GIT SVN

2. Hacking. Just usual GIT
git checkout –b <branch>
hacking…
git commit
hacking…
GIT SVN

3. Updating from SVN
git svn rebase
or
git svn fetch
git svn rebase –l
GIT SVN

4. Preparing your work
git rebase –i remote/<branch>
GIT SVN

5. Committing back to SVN
git svn dcommit
GIT SVN

6. Branching:
git svn branch
GIT internals

.git content
HEAD – the checked out branch
config – configuration options
description – description (used by GitWeb)
hooks/
index - staging
info/
objects/ - content
refs/ - pointers to commit objects in branches
GIT internals

Git is a content-addressable filesystem.
This means that at the core of Git is a simple
key-value data store.
You can insert any kind of content into it, and it
will give you back a key that you can use to
retrieve the content again at any time.
git hash-object – stores the file in GIT
GIT internals

git cat-file - provides content or type and size
information for repository objects

BLOB – basic object type. Every file is stored in it
GIT internals

Tree object
GIT internals

Tree object
git update-index
git write-tree
git read-tree
GIT internals

Commit Objects
git commit-tree
GIT internals

Git References
git update-ref
Questions?
Useful links
http://progit.org/book/
Git Workflow – GitHub
Git SVN Workflow
http://maymay.net/blog/2009/02/24/how-to-
use-git-svn-as-the-only-subversion-client-youll-
need/
and many-many-many others…

Contenu connexe

Tendances

Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflowsArthur Shvetsov
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial IJim Yeh
 
Git introduction workshop for scientists
Git introduction workshop for scientists Git introduction workshop for scientists
Git introduction workshop for scientists Steven Hamblin
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Simplilearn
 
Git tutorial
Git tutorialGit tutorial
Git tutorialmobaires
 
Git extension-training
Git extension-trainingGit extension-training
Git extension-trainingEric Guo
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & GitJason Byrne
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control SystemKMS Technology
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitColin Su
 
Git Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-FlowGit Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-FlowMikhail Melnik
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitE Carter
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitLukas Fittl
 

Tendances (20)

Git commands
Git commandsGit commands
Git commands
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 
Git basics
Git basicsGit basics
Git basics
 
Git introduction workshop for scientists
Git introduction workshop for scientists Git introduction workshop for scientists
Git introduction workshop for scientists
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 
Git
GitGit
Git
 
Git basic
Git basicGit basic
Git basic
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Git extension-training
Git extension-trainingGit extension-training
Git extension-training
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control System
 
01 - Git vs SVN
01 - Git vs SVN01 - Git vs SVN
01 - Git vs SVN
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-FlowGit Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-Flow
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
Git undo
Git undoGit undo
Git undo
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
An Introduction to Git
An Introduction to GitAn Introduction to Git
An Introduction to Git
 

Similaire à Git

Similaire à Git (20)

Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
 
Git and git hub
Git and git hubGit and git hub
Git and git hub
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
 
Git
GitGit
Git
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Improving your workflow with git
Improving your workflow with gitImproving your workflow with git
Improving your workflow with git
 
GDSC GIT AND GITHUB
GDSC GIT AND GITHUB GDSC GIT AND GITHUB
GDSC GIT AND GITHUB
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
How to use git without rage
How to use git without rageHow to use git without rage
How to use git without rage
 
Version control git day03
Version control   git day03Version control   git day03
Version control git day03
 
Git
GitGit
Git
 
Git Distributed Version Control System
Git   Distributed Version Control SystemGit   Distributed Version Control System
Git Distributed Version Control System
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
git Technologies
git Technologiesgit Technologies
git Technologies
 
Using Subversion and Git Together
Using Subversion and Git TogetherUsing Subversion and Git Together
Using Subversion and Git Together
 
Version control git day02
Version control   git day02Version control   git day02
Version control git day02
 
Git basic stanley hsiao 2010_12_15
Git basic stanley hsiao 2010_12_15Git basic stanley hsiao 2010_12_15
Git basic stanley hsiao 2010_12_15
 
Introduction into Git
Introduction into GitIntroduction into Git
Introduction into Git
 
Git
GitGit
Git
 
Git
GitGit
Git
 

Plus de IT Booze

Erlang - concurrency-oriented programming by Serhiy Yvtyshenko
Erlang - concurrency-oriented programming by Serhiy YvtyshenkoErlang - concurrency-oriented programming by Serhiy Yvtyshenko
Erlang - concurrency-oriented programming by Serhiy YvtyshenkoIT Booze
 
Cloud Providers: Amazon, Rackspace, Azure by Andriy Tsok
Cloud Providers: Amazon, Rackspace, Azure by Andriy TsokCloud Providers: Amazon, Rackspace, Azure by Andriy Tsok
Cloud Providers: Amazon, Rackspace, Azure by Andriy TsokIT Booze
 
Let's teach your child programming with Greenfoot by Oleg Pashkevych
Let's teach your child programming with Greenfoot by Oleg Pashkevych Let's teach your child programming with Greenfoot by Oleg Pashkevych
Let's teach your child programming with Greenfoot by Oleg Pashkevych IT Booze
 
Overview of Google spreadsheet API for Java by Nazar Kostiv
Overview of Google spreadsheet API for Java by Nazar Kostiv Overview of Google spreadsheet API for Java by Nazar Kostiv
Overview of Google spreadsheet API for Java by Nazar Kostiv IT Booze
 
Microsoft Dynamics CRM Overview by Anatoly Kvasnikov
Microsoft Dynamics CRM Overview by Anatoly KvasnikovMicrosoft Dynamics CRM Overview by Anatoly Kvasnikov
Microsoft Dynamics CRM Overview by Anatoly KvasnikovIT Booze
 
Windows Phone and mobile application development
Windows Phone and mobile application developmentWindows Phone and mobile application development
Windows Phone and mobile application developmentIT Booze
 
Windows 8 and Metro design applications
Windows 8 and Metro design applicationsWindows 8 and Metro design applications
Windows 8 and Metro design applicationsIT Booze
 
Introduction to mercurial
Introduction to mercurialIntroduction to mercurial
Introduction to mercurialIT Booze
 

Plus de IT Booze (9)

Erlang - concurrency-oriented programming by Serhiy Yvtyshenko
Erlang - concurrency-oriented programming by Serhiy YvtyshenkoErlang - concurrency-oriented programming by Serhiy Yvtyshenko
Erlang - concurrency-oriented programming by Serhiy Yvtyshenko
 
Cloud Providers: Amazon, Rackspace, Azure by Andriy Tsok
Cloud Providers: Amazon, Rackspace, Azure by Andriy TsokCloud Providers: Amazon, Rackspace, Azure by Andriy Tsok
Cloud Providers: Amazon, Rackspace, Azure by Andriy Tsok
 
Let's teach your child programming with Greenfoot by Oleg Pashkevych
Let's teach your child programming with Greenfoot by Oleg Pashkevych Let's teach your child programming with Greenfoot by Oleg Pashkevych
Let's teach your child programming with Greenfoot by Oleg Pashkevych
 
Overview of Google spreadsheet API for Java by Nazar Kostiv
Overview of Google spreadsheet API for Java by Nazar Kostiv Overview of Google spreadsheet API for Java by Nazar Kostiv
Overview of Google spreadsheet API for Java by Nazar Kostiv
 
Microsoft Dynamics CRM Overview by Anatoly Kvasnikov
Microsoft Dynamics CRM Overview by Anatoly KvasnikovMicrosoft Dynamics CRM Overview by Anatoly Kvasnikov
Microsoft Dynamics CRM Overview by Anatoly Kvasnikov
 
Windows Phone and mobile application development
Windows Phone and mobile application developmentWindows Phone and mobile application development
Windows Phone and mobile application development
 
Windows 8 and Metro design applications
Windows 8 and Metro design applicationsWindows 8 and Metro design applications
Windows 8 and Metro design applications
 
Savana
SavanaSavana
Savana
 
Introduction to mercurial
Introduction to mercurialIntroduction to mercurial
Introduction to mercurial
 

Dernier

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
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
 

Dernier (20)

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
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.
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
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
 

Git

  • 1. GIT By Serhiy Yakovyn
  • 2. Agenda • Describe how GIT commands corresponds to SubVersioN ones. • Provide some commonly used workflows. • Explain how to use GIT when your team works with SVN. • Give a quick overview of GIT internals
  • 3. GIT to SVN mapping Create the new repo: svnadmin create repo svn import file://repo git init git add . git commit
  • 4. GIT to SVN mapping To revert: svn revert path Git checkout path
  • 5. GIT to SVN mapping To commit: svn commit git commit -a
  • 6. GIT to SVN mapping Branching: svn copy http://example.com/svn/trunk http://example.com/svn/branches/branch svn switch http://example.com/svn/branches/branch git branch branch git checkout branch
  • 7. GIT to SVN mapping List: svn list http://example.com/svn/branches/ git branch
  • 8. GIT to SVN mapping Moving between revisions: svn update -r rev svn update git checkout rev git checkout prevbranch
  • 9. GIT to SVN mapping (assuming the branch was created in revision 20 and you are inside a working copy of trunk) svn merge -r 20:HEAD http://example.com/svn/branches/branch git merge branch
  • 10. GIT to SVN mapping Pick commit from another branch: svn merge -c rev url git cherry-pick rev
  • 11. GIT to SVN mapping Cloning remote repo: svn checkout url git clone url
  • 12. GIT to SVN mapping Remote branch: svn switch url git checkout --track -b branch origin/branch
  • 13. GIT to SVN mapping Remote update: svn update git pull
  • 14. GIT to SVN mapping Remote commit: svn commit git push
  • 15. Some commonly used workflows 1. Write new features in feature branches. 2. Integrate on the master branch. 3. Deploy from the release branch.
  • 16. Some commonly used workflows 1. Write new features in feature branches. # create a new feature branch in the remote repo named feature_branch git push origin master:refs/heads/feature_branch # make sure we've got everything updated from the remote repo git fetch origin # create a local branch named feature_branch that tracks # the remote feature_branch git branch --track feature_branch origin/feature_branch # check out the new branch git checkout feature_branch
  • 17. Some commonly used workflows 2. Integrate on master branch. git merge master git checkout master git merge feature_branch # this has to be in competition for one of the least intuitive # commands ever, but it removes the remote branch git push origin :refs/heads/feature_branch # remove the local branch git branch -d feature_branch
  • 18. Some commonly used workflows 3. Deploy from the release branch. # checkout the deploy branch git checkout deploy # pull the deploy branch, just to be sure everything's up to date git pull origin deploy # merge the master branch into the deploy branch git merge master # tag the release that we're about to make git tag -a -m "My comments about this release" [tag_name] # push it all up to the remote repository git push --tags origin deploy # switch back to the master branch, # since we never do any work on the deploy branch git checkout master
  • 19. Some commonly used workflows 1. Pull to update your local master 2. Check out a feature branch 3. Do work in your feature branch, committing early and often 4. Rebase frequently to incorporate upstream changes 5. Interactive rebase (squash) your commits 6. Merge your changes with master 7. Push your changes to the upstream
  • 20. Some commonly used workflows 1. Pull to update your local master git checkout master git pull origin master
  • 21. Some commonly used workflows 2. Check out a branch git checkout -b <branch>
  • 22. Some commonly used workflows 3. Do work in your feature branch, committing early and often Hacking… git commit Hacking… git commit Hacking… git commit
  • 23. Some commonly used workflows 4. Rebase frequently to incorporate upstream changes git fetch origin master git rebase origin/master Or (longer way): git checkout master git pull git checkout <branch> git rebase master
  • 24. Some commonly used workflows 5. Interactive rebase (squash) your commits git rebase -i origin/master
  • 25. Some commonly used workflows 6. Merge your changes with master git checkout master git pull git merge <branch>
  • 26. Some commonly used workflows 7. Push your changes to the upstream git push origin master
  • 27. GIT SVN How to use GIT when your team works with SVN? 1. Creating working copy? – no! working repo. git svn init … Some magic  git svn fetch Or (if you are lucky! – I’ve never been): git svn clone …
  • 28. GIT SVN 2. Hacking. Just usual GIT git checkout –b <branch> hacking… git commit hacking…
  • 29. GIT SVN 3. Updating from SVN git svn rebase or git svn fetch git svn rebase –l
  • 30. GIT SVN 4. Preparing your work git rebase –i remote/<branch>
  • 31. GIT SVN 5. Committing back to SVN git svn dcommit
  • 33. GIT internals .git content HEAD – the checked out branch config – configuration options description – description (used by GitWeb) hooks/ index - staging info/ objects/ - content refs/ - pointers to commit objects in branches
  • 34. GIT internals Git is a content-addressable filesystem. This means that at the core of Git is a simple key-value data store. You can insert any kind of content into it, and it will give you back a key that you can use to retrieve the content again at any time. git hash-object – stores the file in GIT
  • 35. GIT internals git cat-file - provides content or type and size information for repository objects BLOB – basic object type. Every file is stored in it
  • 37. GIT internals Tree object git update-index git write-tree git read-tree
  • 41. Useful links http://progit.org/book/ Git Workflow – GitHub Git SVN Workflow http://maymay.net/blog/2009/02/24/how-to- use-git-svn-as-the-only-subversion-client-youll- need/ and many-many-many others…