SlideShare a Scribd company logo
git submodule

         Olaf Alders
 olaf@wundercounter.com
twitter.com/wundercounter
   Toronto Perl Mongers
       Sept 29, 2011
What does it do?

Git's submodule support allows a repository to contain, as a subdirectory, a checkout of an external project.
Submodules maintain their own identity; the submodule support just stores the submodule repository location and
commit ID, so other developers who clone the containing project ("superproject") can easily clone all the
submodules at the same revision. Partial checkouts of the superproject are possible: you can tell Git to clone none,
some or all of the submodules.

source: "Git Community Book"
http://book.git-scm.com/5_submodules.html
An Example:

mkdir shiny_app
cd shiny_app/
git init
mkdir inc
mkdir -p root/static/js
mkdir -p root/static/css
echo "shiny app" > README
git add .
git commit -a -m "initial commit"
Add a submodule

git submodule add https://github.com/twitter/bootstrap.git inc/bootstrap

git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: .gitmodules
# new file: inc/bootstrap

cat .gitmodules
[submodule "inc/bootstrap"]
path = inc/bootstrap
url = https://github.com/twitter/bootstrap.git

git commit -a -m "adds bootstrap as submodule"
Link it up!

mkdir root/static/css
mkdir root/static/js
ln -s inc/bootstrap/bootstrap.min.css root/static/css/
ln -s inc/bootstrap/js root/static/js/bootstrap

git commit root -m "adds bootstrap symlinks"
Now what?

  ● Work as you normally would
  ● Later, when you want to update bootstrap to the latest version

cd inc/bootstrap
git pull origin master
cd ../..
git commit inc/bootstrap -m "updates bootstrap"
Cloning repos with submodules

When someone else clones your repo, they need to update and init:

$ cd ..
git clone shiny_app bootstrapper
Cloning into bootstrapper...
done.

$ cd bootstrapper/
$ ls
README inc root
olaf-alderss-macbook-pro:bootstrapper olaf

$ ls inc/bootstrap/

# no output above -- the inc/bootstrap folder is empty
Remember to init and update

We've got the repo, but the submodule is empty. Two commands will fix that.

$ git submodule init
Submodule 'inc/bootstrap' (https://github.com/twitter/bootstrap.git) registered
for path 'inc/bootstrap'

$ git submodule update
Cloning into inc/bootstrap...
remote: Counting objects: 3845, done.
remote: Compressing objects: 100% (1430/1430), done.
remote: Total 3845 (delta 2474), reused 3663 (delta 2329)
Receiving objects: 100% (3845/3845), 1.04 MiB | 388 KiB/s, done.
Resolving deltas: 100% (2474/2474), done.
Submodule path 'inc/bootstrap': checked out
'28c770bf679e131cc030c3bc4a1981450f831908'
Is your HEAD detached?

By default, the submodule in the cloned repo will not be on a
branch:

cd inc/bootstrap/
git branch
* (no branch)
  master

Try to remember to work on a branch before committing:

$ git checkout master
Oops!

If you commit while not on a branch, you'll get the following "detached HEAD"
message:

$ git commit README.md -m "random change"
[detached HEAD b92b798] random change
 1 files changed, 3 insertions(+), 0 deletions(-)

This is easy to recover from. Just check out a branch and merge the commit:

$ git checkout master
$ git merge b92b798
git pull != git submodule update

Team members should remember to change their workflow to:

git pull origin master
git submodule update

Remember, a pull does not fetch submodule updates. To stay
totally in sync, team members will want to update submodules
as they pull.
Caveat

Merge conflicts
If two team members commit the same submodule with
differing HEADs, you will get a merge conflict. You will need to
resolve this manually.
What do you gain from submodules?

 ● You can build and test against bleeding edge checkouts
 ● You don't have to add someone else's code to your repo
 ● Team members can build against exactly the checkout you've built and
   tested against and vice versa
 ● Updating your submodules is trivial

More Related Content

What's hot

Introduction git
Introduction gitIntroduction git
Introduction git
Dian Sigit Prastowo
 
ノンプログラマでも今日から使える「Git」でバージョン管理
ノンプログラマでも今日から使える「Git」でバージョン管理ノンプログラマでも今日から使える「Git」でバージョン管理
ノンプログラマでも今日から使える「Git」でバージョン管理
H2O Space. Co., Ltd.
 
Gitはじめの一歩
Gitはじめの一歩Gitはじめの一歩
Gitはじめの一歩
Ayana Yokota
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
Panagiotis Papadopoulos
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
Sage Sharp
 
ノンプログラマのGit入門
ノンプログラマのGit入門ノンプログラマのGit入門
ノンプログラマのGit入門
Muyuu Fujita
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
Senthilkumar Gopal
 
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
E Carter
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
Arulmurugan Rajaraman
 
Git pour les (pas si) nuls
Git pour les (pas si) nulsGit pour les (pas si) nuls
Git pour les (pas si) nuls
Malk Zameth
 
Versioning avec Git
Versioning avec GitVersioning avec Git
Versioning avec Git
Jean-Baptiste Vigneron
 
Git commands
Git commandsGit commands
Git commands
Viyaan Jhiingade
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
Anurag Upadhaya
 
Gitのよく使うコマンド
Gitのよく使うコマンドGitのよく使うコマンド
Gitのよく使うコマンドYUKI Kaoru
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
Somkiat Puisungnoen
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
"FENG "GEORGE"" YU
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
glen_a_smith
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
Behzad Altaf
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
Geoff Hoffman
 
やりなおせる Git 入門
やりなおせる Git 入門やりなおせる Git 入門
やりなおせる Git 入門
Tomohiko Himura
 

What's hot (20)

Introduction git
Introduction gitIntroduction git
Introduction git
 
ノンプログラマでも今日から使える「Git」でバージョン管理
ノンプログラマでも今日から使える「Git」でバージョン管理ノンプログラマでも今日から使える「Git」でバージョン管理
ノンプログラマでも今日から使える「Git」でバージョン管理
 
Gitはじめの一歩
Gitはじめの一歩Gitはじめの一歩
Gitはじめの一歩
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
ノンプログラマのGit入門
ノンプログラマのGit入門ノンプログラマのGit入門
ノンプログラマのGit入門
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
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 for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git pour les (pas si) nuls
Git pour les (pas si) nulsGit pour les (pas si) nuls
Git pour les (pas si) nuls
 
Versioning avec Git
Versioning avec GitVersioning avec Git
Versioning avec Git
 
Git commands
Git commandsGit commands
Git commands
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Gitのよく使うコマンド
Gitのよく使うコマンドGitのよく使うコマンド
Gitのよく使うコマンド
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
 
やりなおせる Git 入門
やりなおせる Git 入門やりなおせる Git 入門
やりなおせる Git 入門
 

Viewers also liked

Recycling
RecyclingRecycling
Recycling
guestd12f51
 
Git Submodules
Git SubmodulesGit Submodules
Git Submodules
Maciej Lasyk
 
Advanced Git: Functionality and Features
Advanced Git: Functionality and FeaturesAdvanced Git: Functionality and Features
Advanced Git: Functionality and Features
Brent Laster
 
10th php indonesia surabaya meetup
10th php indonesia surabaya meetup10th php indonesia surabaya meetup
10th php indonesia surabaya meetup
Taufan Aditya
 
Working with multiple git repositories
Working with multiple git repositoriesWorking with multiple git repositories
Working with multiple git repositories
Julien Pivotto
 
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun StuffAdvanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Atlassian
 
Mobile App Test Strategy
Mobile App Test StrategyMobile App Test Strategy
Mobile App Test Strategykraqa
 
Fetch apiについて
Fetch apiについてFetch apiについて
Fetch apiについて
Masakazu Muraoka
 
Grafico diario del dax perfomance index para el 10 04-2013
Grafico diario del dax perfomance index para el 10 04-2013Grafico diario del dax perfomance index para el 10 04-2013
Grafico diario del dax perfomance index para el 10 04-2013
Experiencia Trading
 
Grafico diario del dax perfomance index para el 12 02-2013
Grafico diario del dax perfomance index para el 12 02-2013Grafico diario del dax perfomance index para el 12 02-2013
Grafico diario del dax perfomance index para el 12 02-2013
Experiencia Trading
 
Prueba de portada
Prueba de portadaPrueba de portada
Prueba de portada
patricio
 
Universidad nacional de chimborazo
Universidad nacional de chimborazoUniversidad nacional de chimborazo
Universidad nacional de chimborazo
Banesa Ruiz
 
Quiz families march 2105 quiz
Quiz families march 2105 quizQuiz families march 2105 quiz
Quiz families march 2105 quiz
Arun Anantharaman
 
How to build brands and influence people
How to build brands and influence peopleHow to build brands and influence people
How to build brands and influence people
mattsadler
 
Chan presentation final
Chan presentation finalChan presentation final
Chan presentation final
Daniel Chan
 
コイルのスパイスモデル
コイルのスパイスモデルコイルのスパイスモデル
コイルのスパイスモデル
Tsuyoshi Horigome
 
Wang - A practical model for curricular integration of information literacy i...
Wang - A practical model for curricular integration of information literacy i...Wang - A practical model for curricular integration of information literacy i...
Wang - A practical model for curricular integration of information literacy i...
IL Group (CILIP Information Literacy Group)
 
Figuras literarias
Figuras literariasFiguras literarias
Figuras literarias
Karen Guerra
 
"Using Blockchain Technology to Maintain OERs and IPs" by Sherry Jones (April...
"Using Blockchain Technology to Maintain OERs and IPs" by Sherry Jones (April..."Using Blockchain Technology to Maintain OERs and IPs" by Sherry Jones (April...
"Using Blockchain Technology to Maintain OERs and IPs" by Sherry Jones (April...
Sherry Jones
 

Viewers also liked (19)

Recycling
RecyclingRecycling
Recycling
 
Git Submodules
Git SubmodulesGit Submodules
Git Submodules
 
Advanced Git: Functionality and Features
Advanced Git: Functionality and FeaturesAdvanced Git: Functionality and Features
Advanced Git: Functionality and Features
 
10th php indonesia surabaya meetup
10th php indonesia surabaya meetup10th php indonesia surabaya meetup
10th php indonesia surabaya meetup
 
Working with multiple git repositories
Working with multiple git repositoriesWorking with multiple git repositories
Working with multiple git repositories
 
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun StuffAdvanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
 
Mobile App Test Strategy
Mobile App Test StrategyMobile App Test Strategy
Mobile App Test Strategy
 
Fetch apiについて
Fetch apiについてFetch apiについて
Fetch apiについて
 
Grafico diario del dax perfomance index para el 10 04-2013
Grafico diario del dax perfomance index para el 10 04-2013Grafico diario del dax perfomance index para el 10 04-2013
Grafico diario del dax perfomance index para el 10 04-2013
 
Grafico diario del dax perfomance index para el 12 02-2013
Grafico diario del dax perfomance index para el 12 02-2013Grafico diario del dax perfomance index para el 12 02-2013
Grafico diario del dax perfomance index para el 12 02-2013
 
Prueba de portada
Prueba de portadaPrueba de portada
Prueba de portada
 
Universidad nacional de chimborazo
Universidad nacional de chimborazoUniversidad nacional de chimborazo
Universidad nacional de chimborazo
 
Quiz families march 2105 quiz
Quiz families march 2105 quizQuiz families march 2105 quiz
Quiz families march 2105 quiz
 
How to build brands and influence people
How to build brands and influence peopleHow to build brands and influence people
How to build brands and influence people
 
Chan presentation final
Chan presentation finalChan presentation final
Chan presentation final
 
コイルのスパイスモデル
コイルのスパイスモデルコイルのスパイスモデル
コイルのスパイスモデル
 
Wang - A practical model for curricular integration of information literacy i...
Wang - A practical model for curricular integration of information literacy i...Wang - A practical model for curricular integration of information literacy i...
Wang - A practical model for curricular integration of information literacy i...
 
Figuras literarias
Figuras literariasFiguras literarias
Figuras literarias
 
"Using Blockchain Technology to Maintain OERs and IPs" by Sherry Jones (April...
"Using Blockchain Technology to Maintain OERs and IPs" by Sherry Jones (April..."Using Blockchain Technology to Maintain OERs and IPs" by Sherry Jones (April...
"Using Blockchain Technology to Maintain OERs and IPs" by Sherry Jones (April...
 

Similar to Git submodule

Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)
Boise Web Technologies Group
 
Transformative Git Practices
Transformative Git PracticesTransformative Git Practices
Transformative Git Practices
Nicola Paolucci
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
Rick Umali
 
Using Git as your VCS with Bioconductor
Using Git as your VCS with BioconductorUsing Git as your VCS with Bioconductor
Using Git as your VCS with Bioconductor
timyates
 
Switching to Git
Switching to GitSwitching to Git
Switching to Git
Stephen Yeargin
 
Jedi Mind Tricks for Git
Jedi Mind Tricks for GitJedi Mind Tricks for Git
Jedi Mind Tricks for Git
Jan Krag
 
Practical git for developers
Practical git for developersPractical git for developers
Practical git for developers
Wim Godden
 
Getting Into Git
Getting Into GitGetting Into Git
Getting Into Git
Rick Umali
 
How to use git without rage
How to use git without rageHow to use git without rage
How to use git without rage
Javier Lafora Rey
 
Git, from the beginning
Git, from the beginningGit, from the beginning
Git, from the beginning
James Aylett
 
Jedi Mind Tricks in Git
Jedi Mind Tricks in GitJedi Mind Tricks in Git
Jedi Mind Tricks in Git
Johan Abildskov
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
Alberto Leal
 
Git single branch
Git single branchGit single branch
Git single branch
Carl Brown
 
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -EssentialsJAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials
jazoon13
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
alignan
 
GitLab on OpenShift
GitLab on OpenShiftGitLab on OpenShift
Getting Started with Git
Getting Started with GitGetting Started with Git
Getting Started with Git
Rick Umali
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
Becky Todd
 
Git and Github workshop
Git and Github workshopGit and Github workshop
Git and Github workshop
Otto Kekäläinen
 
Git the Docs: Learning Git in a safe space
Git the Docs: Learning Git in a safe spaceGit the Docs: Learning Git in a safe space
Git the Docs: Learning Git in a safe space
Becky Todd
 

Similar to Git submodule (20)

Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)
 
Transformative Git Practices
Transformative Git PracticesTransformative Git Practices
Transformative Git Practices
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Using Git as your VCS with Bioconductor
Using Git as your VCS with BioconductorUsing Git as your VCS with Bioconductor
Using Git as your VCS with Bioconductor
 
Switching to Git
Switching to GitSwitching to Git
Switching to Git
 
Jedi Mind Tricks for Git
Jedi Mind Tricks for GitJedi Mind Tricks for Git
Jedi Mind Tricks for Git
 
Practical git for developers
Practical git for developersPractical git for developers
Practical git for developers
 
Getting Into Git
Getting Into GitGetting Into Git
Getting Into Git
 
How to use git without rage
How to use git without rageHow to use git without rage
How to use git without rage
 
Git, from the beginning
Git, from the beginningGit, from the beginning
Git, from the beginning
 
Jedi Mind Tricks in Git
Jedi Mind Tricks in GitJedi Mind Tricks in Git
Jedi Mind Tricks in Git
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Git single branch
Git single branchGit single branch
Git single branch
 
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -EssentialsJAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials
JAZOON'13 - Thomas Hug & Bartosz Majsak - Git Workshop -Essentials
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
 
GitLab on OpenShift
GitLab on OpenShiftGitLab on OpenShift
GitLab on OpenShift
 
Getting Started with Git
Getting Started with GitGetting Started with Git
Getting Started with Git
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
 
Git and Github workshop
Git and Github workshopGit and Github workshop
Git and Github workshop
 
Git the Docs: Learning Git in a safe space
Git the Docs: Learning Git in a safe spaceGit the Docs: Learning Git in a safe space
Git the Docs: Learning Git in a safe space
 

More from Olaf Alders

No Hugging, No Learning
No Hugging, No LearningNo Hugging, No Learning
No Hugging, No Learning
Olaf Alders
 
The MetaCPAN VM Part II (Using the VM)
The MetaCPAN VM Part II (Using the VM)The MetaCPAN VM Part II (Using the VM)
The MetaCPAN VM Part II (Using the VM)
Olaf Alders
 
The MetaCPAN VM for Dummies Part One (Installation)
The MetaCPAN VM for Dummies Part One (Installation)The MetaCPAN VM for Dummies Part One (Installation)
The MetaCPAN VM for Dummies Part One (Installation)
Olaf Alders
 
Ab(Using) the MetaCPAN API for Fun and Profit v2013
Ab(Using) the MetaCPAN API for Fun and Profit v2013Ab(Using) the MetaCPAN API for Fun and Profit v2013
Ab(Using) the MetaCPAN API for Fun and Profit v2013
Olaf Alders
 
(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit
Olaf Alders
 
Mangling
Mangling Mangling
Mangling
Olaf Alders
 

More from Olaf Alders (6)

No Hugging, No Learning
No Hugging, No LearningNo Hugging, No Learning
No Hugging, No Learning
 
The MetaCPAN VM Part II (Using the VM)
The MetaCPAN VM Part II (Using the VM)The MetaCPAN VM Part II (Using the VM)
The MetaCPAN VM Part II (Using the VM)
 
The MetaCPAN VM for Dummies Part One (Installation)
The MetaCPAN VM for Dummies Part One (Installation)The MetaCPAN VM for Dummies Part One (Installation)
The MetaCPAN VM for Dummies Part One (Installation)
 
Ab(Using) the MetaCPAN API for Fun and Profit v2013
Ab(Using) the MetaCPAN API for Fun and Profit v2013Ab(Using) the MetaCPAN API for Fun and Profit v2013
Ab(Using) the MetaCPAN API for Fun and Profit v2013
 
(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit
 
Mangling
Mangling Mangling
Mangling
 

Recently uploaded

“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 

Recently uploaded (20)

“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 

Git submodule

  • 1. git submodule Olaf Alders olaf@wundercounter.com twitter.com/wundercounter Toronto Perl Mongers Sept 29, 2011
  • 2. What does it do? Git's submodule support allows a repository to contain, as a subdirectory, a checkout of an external project. Submodules maintain their own identity; the submodule support just stores the submodule repository location and commit ID, so other developers who clone the containing project ("superproject") can easily clone all the submodules at the same revision. Partial checkouts of the superproject are possible: you can tell Git to clone none, some or all of the submodules. source: "Git Community Book" http://book.git-scm.com/5_submodules.html
  • 3. An Example: mkdir shiny_app cd shiny_app/ git init mkdir inc mkdir -p root/static/js mkdir -p root/static/css echo "shiny app" > README git add . git commit -a -m "initial commit"
  • 4. Add a submodule git submodule add https://github.com/twitter/bootstrap.git inc/bootstrap git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: .gitmodules # new file: inc/bootstrap cat .gitmodules [submodule "inc/bootstrap"] path = inc/bootstrap url = https://github.com/twitter/bootstrap.git git commit -a -m "adds bootstrap as submodule"
  • 5. Link it up! mkdir root/static/css mkdir root/static/js ln -s inc/bootstrap/bootstrap.min.css root/static/css/ ln -s inc/bootstrap/js root/static/js/bootstrap git commit root -m "adds bootstrap symlinks"
  • 6. Now what? ● Work as you normally would ● Later, when you want to update bootstrap to the latest version cd inc/bootstrap git pull origin master cd ../.. git commit inc/bootstrap -m "updates bootstrap"
  • 7. Cloning repos with submodules When someone else clones your repo, they need to update and init: $ cd .. git clone shiny_app bootstrapper Cloning into bootstrapper... done. $ cd bootstrapper/ $ ls README inc root olaf-alderss-macbook-pro:bootstrapper olaf $ ls inc/bootstrap/ # no output above -- the inc/bootstrap folder is empty
  • 8. Remember to init and update We've got the repo, but the submodule is empty. Two commands will fix that. $ git submodule init Submodule 'inc/bootstrap' (https://github.com/twitter/bootstrap.git) registered for path 'inc/bootstrap' $ git submodule update Cloning into inc/bootstrap... remote: Counting objects: 3845, done. remote: Compressing objects: 100% (1430/1430), done. remote: Total 3845 (delta 2474), reused 3663 (delta 2329) Receiving objects: 100% (3845/3845), 1.04 MiB | 388 KiB/s, done. Resolving deltas: 100% (2474/2474), done. Submodule path 'inc/bootstrap': checked out '28c770bf679e131cc030c3bc4a1981450f831908'
  • 9. Is your HEAD detached? By default, the submodule in the cloned repo will not be on a branch: cd inc/bootstrap/ git branch * (no branch) master Try to remember to work on a branch before committing: $ git checkout master
  • 10. Oops! If you commit while not on a branch, you'll get the following "detached HEAD" message: $ git commit README.md -m "random change" [detached HEAD b92b798] random change 1 files changed, 3 insertions(+), 0 deletions(-) This is easy to recover from. Just check out a branch and merge the commit: $ git checkout master $ git merge b92b798
  • 11. git pull != git submodule update Team members should remember to change their workflow to: git pull origin master git submodule update Remember, a pull does not fetch submodule updates. To stay totally in sync, team members will want to update submodules as they pull.
  • 12. Caveat Merge conflicts If two team members commit the same submodule with differing HEADs, you will get a merge conflict. You will need to resolve this manually.
  • 13. What do you gain from submodules? ● You can build and test against bleeding edge checkouts ● You don't have to add someone else's code to your repo ● Team members can build against exactly the checkout you've built and tested against and vice versa ● Updating your submodules is trivial