* . *
  • About
  • Advertise
  • Privacy & Policy
  • Contact
Sunday, September 7, 2025
Earth-News
  • Home
  • Business
  • Entertainment
    Victor Garber on his viral “And Just Like That” toilet scene: ‘I was delighted to be doing something ridiculous’ (exclusive) – yahoo.com

    Victor Garber on his viral “And Just Like That” toilet scene: ‘I was delighted to be doing something ridiculous’ (exclusive) – yahoo.com

    Pendulum Announce Homecoming 2026 Australian Tour – yahoo.com

    Pendulum Announces Thrilling Homecoming Tour Across Australia in 2026

    ITV Studios Launches New Entertainment Label – Global Bulletin – IMDb

    ITV Studios Unveils Exciting New Entertainment Label

    TS Entertainment bringing Malibu Jack’s to former Owensboro mall – Lane Report

    TS Entertainment Launches Malibu Jack’s at Former Owensboro Mall Location

    Jenny Han Dropped a Major ‘The Summer I Turned Pretty’ Easter Egg Revealing [SPOILER] – yahoo.com

    Jenny Han Just Unveiled a Huge ‘The Summer I Turned Pretty’ Easter Egg That Changes Everything [SPOILER]

    Liam Payne’s Cousin Ross Harris Honors Late Singer With Emotional Song ‘Bones’ – yahoo.com

    Liam Payne’s Cousin Ross Harris Honors Late Singer with Emotional New Song ‘Bones

  • General
  • Health
  • News

    Cracking the Code: Why China’s Economic Challenges Aren’t Shaking Markets, Unlike America’s” – Bloomberg

    Trump’s Narrow Window to Spread the Truth About Harris

    Trump’s Narrow Window to Spread the Truth About Harris

    Israel-Gaza war live updates: Hamas leader Ismail Haniyeh assassinated in Iran, group says

    Israel-Gaza war live updates: Hamas leader Ismail Haniyeh assassinated in Iran, group says

    PAP Boss to Niger Delta Youths, Stay Away from the Protest

    PAP Boss to Niger Delta Youths, Stay Away from the Protest

    Court Restricts Protests In Lagos To Freedom, Peace Park

    Court Restricts Protests In Lagos To Freedom, Peace Park

    Fans React to Jazz Jennings’ Inspiring Weight Loss Journey

    Fans React to Jazz Jennings’ Inspiring Weight Loss Journey

    Trending Tags

    • Trump Inauguration
    • United Stated
    • White House
    • Market Stories
    • Election Results
  • Science
  • Sports
  • Technology
    Coherent Joins LLNL’s STARFIRE Diode Technology Working Group to Advance Inertial Fusion Energy – GlobeNewswire

    Coherent Partners with LLNL’s STARFIRE Team to Drive Breakthroughs in Inertial Fusion Energy

    Gene Associated With Deadly Heart Disease in Golden Retrievers Identified – Technology Networks

    Breakthrough Discovery Uncovers Gene Behind Deadly Heart Disease in Golden Retrievers

    Monkey Island LNG Picks ConocoPhillips’ Liquefaction Technology – Hart Energy

    Monkey Island LNG Selects ConocoPhillips’ Advanced Liquefaction Technology for Next-Gen Energy Solutions

    Credo Technology Group Holding Ltd. (CRDO) Surpasses Q1 Earnings and Revenue Estimates – Yahoo Finance

    Credo Technology Group Surpasses Q1 Earnings and Revenue Expectations

    The Economist is hiring a science and technology correspondent – The Economist

    Exciting Opportunity: Become Our Next Science and Technology Correspondent!

    Blockchain lender Figure Technology seeks to raise up to $526M in IPO (FIGR:Pending) – Seeking Alpha

    Blockchain Lender Figure Technology Sets Sights on $526M in Thrilling IPO Launch

    Trending Tags

    • Nintendo Switch
    • CES 2017
    • Playstation 4 Pro
    • Mark Zuckerberg
No Result
View All Result
  • Home
  • Business
  • Entertainment
    Victor Garber on his viral “And Just Like That” toilet scene: ‘I was delighted to be doing something ridiculous’ (exclusive) – yahoo.com

    Victor Garber on his viral “And Just Like That” toilet scene: ‘I was delighted to be doing something ridiculous’ (exclusive) – yahoo.com

    Pendulum Announce Homecoming 2026 Australian Tour – yahoo.com

    Pendulum Announces Thrilling Homecoming Tour Across Australia in 2026

    ITV Studios Launches New Entertainment Label – Global Bulletin – IMDb

    ITV Studios Unveils Exciting New Entertainment Label

    TS Entertainment bringing Malibu Jack’s to former Owensboro mall – Lane Report

    TS Entertainment Launches Malibu Jack’s at Former Owensboro Mall Location

    Jenny Han Dropped a Major ‘The Summer I Turned Pretty’ Easter Egg Revealing [SPOILER] – yahoo.com

    Jenny Han Just Unveiled a Huge ‘The Summer I Turned Pretty’ Easter Egg That Changes Everything [SPOILER]

    Liam Payne’s Cousin Ross Harris Honors Late Singer With Emotional Song ‘Bones’ – yahoo.com

    Liam Payne’s Cousin Ross Harris Honors Late Singer with Emotional New Song ‘Bones

  • General
  • Health
  • News

    Cracking the Code: Why China’s Economic Challenges Aren’t Shaking Markets, Unlike America’s” – Bloomberg

    Trump’s Narrow Window to Spread the Truth About Harris

    Trump’s Narrow Window to Spread the Truth About Harris

    Israel-Gaza war live updates: Hamas leader Ismail Haniyeh assassinated in Iran, group says

    Israel-Gaza war live updates: Hamas leader Ismail Haniyeh assassinated in Iran, group says

    PAP Boss to Niger Delta Youths, Stay Away from the Protest

    PAP Boss to Niger Delta Youths, Stay Away from the Protest

    Court Restricts Protests In Lagos To Freedom, Peace Park

    Court Restricts Protests In Lagos To Freedom, Peace Park

    Fans React to Jazz Jennings’ Inspiring Weight Loss Journey

    Fans React to Jazz Jennings’ Inspiring Weight Loss Journey

    Trending Tags

    • Trump Inauguration
    • United Stated
    • White House
    • Market Stories
    • Election Results
  • Science
  • Sports
  • Technology
    Coherent Joins LLNL’s STARFIRE Diode Technology Working Group to Advance Inertial Fusion Energy – GlobeNewswire

    Coherent Partners with LLNL’s STARFIRE Team to Drive Breakthroughs in Inertial Fusion Energy

    Gene Associated With Deadly Heart Disease in Golden Retrievers Identified – Technology Networks

    Breakthrough Discovery Uncovers Gene Behind Deadly Heart Disease in Golden Retrievers

    Monkey Island LNG Picks ConocoPhillips’ Liquefaction Technology – Hart Energy

    Monkey Island LNG Selects ConocoPhillips’ Advanced Liquefaction Technology for Next-Gen Energy Solutions

    Credo Technology Group Holding Ltd. (CRDO) Surpasses Q1 Earnings and Revenue Estimates – Yahoo Finance

    Credo Technology Group Surpasses Q1 Earnings and Revenue Expectations

    The Economist is hiring a science and technology correspondent – The Economist

    Exciting Opportunity: Become Our Next Science and Technology Correspondent!

    Blockchain lender Figure Technology seeks to raise up to $526M in IPO (FIGR:Pending) – Seeking Alpha

    Blockchain Lender Figure Technology Sets Sights on $526M in Thrilling IPO Launch

    Trending Tags

    • Nintendo Switch
    • CES 2017
    • Playstation 4 Pro
    • Mark Zuckerberg
No Result
View All Result
Earth-News
No Result
View All Result
Home General

How to Turn a Turn a Directory in a Git Repository Into a Submodule

July 16, 2023
in General
How to Turn a Turn a Directory in a Git Repository Into a Submodule
Share on FacebookShare on Twitter

Git submodules are like repositories within repositories, which allow you to include external code libraries or dependencies in your project, all without linking the module’s version control to the project itself. This keeps modules separate and easy to update, and it’s easy to convert a directory into a new submodule.

What is a Submodule in Git?

A submodule is a Git repository that is embedded within another Git repository. This allows you to include code from another project as a dependency, while still maintaining its own version control.

When you clone the parent repository, it automatically clones the submodule repository as well. This means that the submodule’s code and Git history is kept separate from the main version control, and can be updated for multiple repositories that consume the library.

An alternative to submodules is to publish your libraries as packages to package managers like NPM, Maven, or NuGet. However, this doesn’t work for all types of projects, and if you’re working with private code, you’ll need to set up a private package registry, which can be more complicated than simply embedding the library’s source code as a submodule.

One of the main problems with turning an existing directory into a submodule is that the submodule should be managed externally. Git expects you to create a new empty directory for it, and clone the submodule into the project. You can copy the code to a new folder, but you will lose all the Git history related to it, which can be very detrimental in large projects. Instead, we’ll clone the repository, filter out the unneeded code, and push the new history to the new submodule.

How to Turn a Directory Into a Submodule

The first step is to create a new repository for the submodule. This is usually on a Git hosting service like GitHub, though you can create a local repository on your computer.

Next, you will want to get a fresh copy of your main repository to make the submodule repository from.

git clone [email protected]:username/repository.git submodule-repo

cd submodule-repo

Next, you will want to filter out everything that isn’t related to your submodule. This will delete all the commit history that isn’t related to the code contained in the submodule. This is a destructive operation, so make sure you’re doing this on the copy of your repo, not the main one.

git filter-branch –subdirectory-filter submoduledirectory — –all

You’ll be left with only the code that was in the directory, and only the commits pertaining to it. This will let you transfer over all the Git history related to that submodule.

You’ll want to change the remote URL of this module directory to your new submodule repository, which is typically named “origin.”

git remote set-url origin https://github.com/new-repository.git

Then, you can push the history as you normally would.

git push -u origin main

Adding a New Submodule

Back over in the main project, you will want to add the submodule.

First, you need to stop tracking the directory that you want to turn into a submodule from the parent repository. It will still be there in Git’s version history, and you just added it to the new module repository anyway.

rm -rf directory_name

Next, you can add the remote URL for the submodule repository that you created on Github, using the git submodule add command:

git submodule add [email protected]:username/repository.git directory_name

When you run this command, Git will create a new submodule directory in the parent repository, and it will clone the submodule repository into this directory. It will also start tracking the module folder again.

To update the submodule, you can use the git submodule update command:

git submodule update –remote submodule_name

>>> Read full article>>>
Copyright for syndicated content belongs to the linked Source : How To Geek – https://www.howtogeek.com/devops/how-to-turn-a-turn-a-directory-in-a-git-repository-into-a-submodule/

Previous Post

10 Games You Won’t Believe Your M1 or M2 Mac Can Run

Next Post

Keep Your Git Repository History Clean By Squashing Commits

Reformulation of general relativity brings it closer to Newtonian physics – Physics World

Reformulation of general relativity brings it closer to Newtonian physics – Physics World

September 7, 2025
Trump’s Economy Fails Arkansans as Unemployment Reaches Four-Year High – SWARK Today

Trump’s Economy Fails Arkansans as Unemployment Reaches Four-Year High – SWARK Today

September 7, 2025
Victor Garber on his viral “And Just Like That” toilet scene: ‘I was delighted to be doing something ridiculous’ (exclusive) – yahoo.com

Victor Garber on his viral “And Just Like That” toilet scene: ‘I was delighted to be doing something ridiculous’ (exclusive) – yahoo.com

September 7, 2025
Heroes on the Hill event addresses mental health for vets, first responders – CBS News

Heroes on the Hill: Tackling Mental Health Challenges for Vets and First Responders

September 7, 2025

Trump signs executive order creating ‘state sponsor of wrongful detention’ designation – CNN

September 7, 2025
Ecology issues $738K penalty against downtown Walla Walla Chevron owner – Union-Bulletin

Ecology issues $738K penalty against downtown Walla Walla Chevron owner – Union-Bulletin

September 6, 2025
What the science says about acetaminophen, pregnant mothers and autism – NBC News

What the science says about acetaminophen, pregnant mothers and autism – NBC News

September 6, 2025
RFK Jr accused of ‘reckless disregard for science and the truth’ in Senate hearing – The Guardian

RFK Jr. Faces Fierce Backlash for ‘Reckless Disregard for Science and Truth’ in Heated Senate Hearing

September 6, 2025
Start The Go-Go Years Today: Ignite Your Early Retirement Lifestyle – Forbes

Start The Go-Go Years Today: Ignite Your Early Retirement Lifestyle – Forbes

September 6, 2025
When Sports Teach More Than Skills – American Enterprise Institute

When Sports Teach More Than Skills – American Enterprise Institute

September 6, 2025

Categories

Archives

September 2025
MTWTFSS
1234567
891011121314
15161718192021
22232425262728
2930 
« Aug    
Earth-News.info

The Earth News is an independent English-language daily published Website from all around the World News

Browse by Category

  • Business (20,132)
  • Ecology (810)
  • Economy (829)
  • Entertainment (21,706)
  • General (16,893)
  • Health (9,870)
  • Lifestyle (841)
  • News (22,149)
  • People (830)
  • Politics (835)
  • Science (16,039)
  • Sports (21,327)
  • Technology (15,808)
  • World (810)

Recent News

Reformulation of general relativity brings it closer to Newtonian physics – Physics World

Reformulation of general relativity brings it closer to Newtonian physics – Physics World

September 7, 2025
Trump’s Economy Fails Arkansans as Unemployment Reaches Four-Year High – SWARK Today

Trump’s Economy Fails Arkansans as Unemployment Reaches Four-Year High – SWARK Today

September 7, 2025
  • About
  • Advertise
  • Privacy & Policy
  • Contact

© 2023 earth-news.info

No Result
View All Result

© 2023 earth-news.info

No Result
View All Result

© 2023 earth-news.info

Go to mobile version