Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

I can't delete my sub-module

Hello,

I accidentally created my submodule at the wrong location. I want to delete it and re-add it correctly. However, I can't figure out how to delete it.

Capture.PNG

Any help would be appreciated.
Thank you

2 answers

1 accepted

0 votes
Answer accepted

For anyone else coming by later, I ended up finding this ...

"Since git 1.8.5, git mv old/submod new/submod works as expected and does all the plumbing for you. You might want to use git 1.9.3 or newer, because it includes fixes for submodule moving."

via https://stackoverflow.com/questions/4604486/how-do-i-move-an-existing-git-submodule-within-a-git-repository

0 votes
Ana Retamal Atlassian Team Dec 19, 2018

Hi Lester,

The best way to completely remove a submodule would be using the command line, you can follow the steps:

  1. Delete the relevant section from the .gitmodules file.
  2. Stage the .gitmodules changes git add .gitmodules
  3. Delete the relevant section from .git/config.
  4. Run git rm --cached path_to_submodule (no trailing slash).
  5. Run rm -rf .git/modules/path_to_submodule
  6. Commit git commit -m "Removed submodule <name>"
  7. Delete the now untracked submodule files
    rm -rf path_to_submodule

You can also find different approaches in this thread.

Hope that helps!

Ana

Hi @Ana Retamal,

I have a couple follow up questions.

1) My real issue is that I added the submodule to the incorrect path. I was planning on deleting the submodule and then re-creating it. Is it instead possible to move the submodule? I noticed the paths in the .gitmodules; can I edit those? (FYI, I tried this before asking and it didn't work, but maybe I am doing something wrong)

2) I have multiple submodules, and after editing the .gitmodules file, by hand, all my other submodules disappear from sourcetree. Is that expected behavior? I have not completed your steps because I wanted to wait for an answer to this before proceeding too far.

Thank you for the help
Lester

Hi @Ana Retamal,

I was wondering if you had any info regarding those follow up questions I posted above? I have still held off from continuing the process, because I am not entirely sure if #2 is going to cause more trouble for me or not.

Thank you
Lester

Hi @Ana Retamal,

I apologize for the repeated pings. I speculate that maybe this was lost over the holiday breaks. I am having issues with your instructions, and had some follow up questions.

1) My real issue is that I added the submodule to the incorrect path. I was planning on deleting the submodule and then re-creating it. Is it instead possible to move the submodule? I noticed the paths in the .gitmodules; can I edit those? (FYI, I tried this before asking and it didn't work, but maybe I am doing something wrong)


2) I have multiple submodules, and after editing the .gitmodules file, by hand, all my other submodules disappear from sourcetree. Is that expected behavior? I have not completed your steps because I wanted to wait for an answer to this before proceeding too far.

Thank you for the assistance
Lester

if you use git mv -k you can move whole directories that contain multiple git submodules

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

3,266 views 4 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you