Git Submodules Tutorial | For Beginners

Поделиться
HTML-код
  • Опубликовано: 29 сен 2024

Комментарии • 233

  • @warisulimam3440
    @warisulimam3440 2 года назад +42

    Simple and precise explanations, incredibly helpful. Thank you so much!

    • @RedhwanNacef
      @RedhwanNacef  2 года назад +1

      Thanks! Glad you enjoyed it 😊

  • @lambertoXD
    @lambertoXD 3 года назад +24

    I was looking for an answer regarding the cloning of submodules and you covered it in an incredibly clear way ! Thanks for that, great video!

    • @RedhwanNacef
      @RedhwanNacef  3 года назад

      You're very welcome, glad it helped! Thank you for the feedback.

  • @Sunil_KumarDas
    @Sunil_KumarDas Год назад +4

    0.75 Playback speed + focus helps.

  • @devstefancho
    @devstefancho 3 года назад +1

    command summary
    git submodule add {child-repo-url}
    # add submodules (this will create .gitmodules)
    git pull --recurse-submodules
    # bring submodule's files
    git config submodule.recurse true
    # always --recurse-submodules
    git clone {parent-repo-url}
    # clone your parent repo which have submodules
    git submodule update --init
    # bring submodule files to this repo

  • @realscreen7735
    @realscreen7735 Год назад +2

    U made some changes to the local repo and comitted them from which u got the submodule. How is git able to figure out that there are changes in the local repo when it is pointing to the remote url and not the local repo from which we got the submodule?

    • @RedhwanNacef
      @RedhwanNacef  Год назад

      Good question, if you remember we have a ".gitmodules" that has a path to the submodule. This is telling git where to track the local changes. This is how it knows there are changes in the local repo. Hope that makes sense.

  • @marmalamuc
    @marmalamuc 2 года назад +4

    Your video really simplified this process for me! One question though:
    In other videos & articles, I've seen people say that, in order to incorporate changes from the submodule's repo, you have to run `git submodule update --remote` in the superproject repo before adding/committing/pushing. It looks like you didn't do that here, but everything worked fine.
    Do you know if `git submodule update --remote` is necessary?

    • @RedhwanNacef
      @RedhwanNacef  2 года назад +4

      Glad it helped.
      The reason I did not need that command here is because I updated the submodule directly from within the parent project. So there were no other changes in the remote. If for example a colleague had updated the submodule else where, my local copy would not know about that, so I would need to ensure it is updated before developing. One way to do it is with the command `git submodule update --remote`, the other would be to `cd` into the submodule repo, checkout master and just do a git pull. Hopefully that makes sense?

  • @richardbaumgartel
    @richardbaumgartel 10 месяцев назад +2

    For me it was a little bit confusing, that the name of the "normal repository" contains the word submodule and the submodule itself didn't. I had to wrap my head around this couple of times but could have been just me.
    Other then that: Great explanation!

  • @nomadshiba
    @nomadshiba 2 года назад +1

    git submodule init ; git submodule update ; git submodule foreach --recursive git checkout master

  • @ashwinswain1649
    @ashwinswain1649 Год назад +1

    Hi,
    I am not able to see the submodule files i guess now i got the answer why.....thanks for that..but what if i want to undo and make it invisible again?
    also how can i add a version tag to the submodules and how can i use a feature branch of repo A as a submodule inside repo B so i can run a github action on B

    • @RedhwanNacef
      @RedhwanNacef  Год назад

      You're welcome. I wonder if the "deinit" command is what you are looking for here? Tags would be added the same as any other repo. In terms of feature branch you can specify the branch in the .gitmodules file. Hopefully that helps!

  • @erich_l4644
    @erich_l4644 Год назад +1

    I don't see why you used "youtube tutorial" repo as an example. Quite a helpful video nevertheless thankyou.

    • @RedhwanNacef
      @RedhwanNacef  Год назад

      The repo doesn't really matter in this case, just the concept. Thanks!

  • @pehucz
    @pehucz День назад

    Nice video 👍 I need to share config files between two Ansible repositories and git submodule with config files looks like a solution.

  • @JayJay-ki4mi
    @JayJay-ki4mi 2 года назад +3

    Redhwan: "This will take a few seconds"
    Boost: "Go grab a coffee"

  • @MaherKheder3
    @MaherKheder3 3 года назад +3

    thank you for Video.
    question: how you can show the options in command line like in min : 14:02 ?

    • @RedhwanNacef
      @RedhwanNacef  3 года назад +2

      Anytime. I use zsh with the git plugin: github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git. which gives me that functionality :)

  • @senr4in
    @senr4in 8 месяцев назад +1

    This is helpful, thanks

  • @maksimbronsky7117
    @maksimbronsky7117 2 года назад +1

    You really look like Ayrton Senna (as the RUclips Algorithm suggests)

  • @EdwinFairchild
    @EdwinFairchild 2 года назад

    howcome everytime i run submodules update, i go look at my submodule and it checksout the commit (now outdated) that i originally made the project with....thought update would fetch the latest commit for me. So im finding to stay up to date I have to go checkout main from my submodule. How to I make my submodule always update to main not the commit i started my repo with

    • @RedhwanNacef
      @RedhwanNacef  2 года назад

      I believe submodule update will only update according to the local remote. Have you tried adding the --remote flag? That should actually fetch and update for you (making the submodule is on the main branch too).

  • @DjSeymur
    @DjSeymur Год назад +1

    Is there a way to do this with branches in the same repository instead of two different repositories ?

    • @RedhwanNacef
      @RedhwanNacef  Год назад

      Not sure, I have never thought to do that. You could always try add the path/url and see if it works?

  • @azharlihan
    @azharlihan 10 месяцев назад

    Thanks for the explanation. Simple and I can easily understand.
    But how to remove submodule completely from main repository? For example, remove youtube-tutorial submodule from git-submodule-tutorial repository?

  • @batfos
    @batfos 2 года назад +1

    Thank you

  • @isholaoluwatomisin1906
    @isholaoluwatomisin1906 Год назад +3

    Detailed explanation to get started with submodules.
    You could also use the "git submodule update --remote" to update the submodules if the changes were made by another member of your team(Not locally).

    • @EddieDemon
      @EddieDemon Год назад

      Biggest question mark I was left with, thanks for answering!

    • @RedhwanNacef
      @RedhwanNacef  Год назад

      Thanks for the additional information.

  • @Quacky_Batak
    @Quacky_Batak 3 года назад +4

    Great tutorial, concise and great explanation. Thanks for showing all the other tutorials name in this video. Earned a sub 👍

    • @RedhwanNacef
      @RedhwanNacef  3 года назад +1

      Thanks for the feedback and the sub. 🙂

  • @matheusglauber4261
    @matheusglauber4261 Год назад +1

    Very good video, very helpful, tks

  • @davidkind9587
    @davidkind9587 3 года назад +4

    great explanation, thanks

  • @hrajabi7261
    @hrajabi7261 Месяц назад

    Detailed and simple, incredibly helpful. Thanks!

  • @baatar
    @baatar 7 месяцев назад

    9:00 if you have cloned your git repo but need to install the submodule, the command is "git submodule update --init"

  • @stanislavlyu1827
    @stanislavlyu1827 10 месяцев назад

    Thank you for the tutorial. I have a question, what about private submodule repo?

  • @androth1502
    @androth1502 Месяц назад

    can you make submodules out of specific folders in a repository?

  • @VitorMartins-l1h
    @VitorMartins-l1h 6 месяцев назад

    but if we have more than one submodule and we want to downoloaded only a specific submodule into the main repo ?

  • @IreshDissanayakaM
    @IreshDissanayakaM 3 года назад +2

    This was great! Nice explanation. Now I can start using git submodules.

  • @joe_j
    @joe_j Год назад +1

    This was really helpful .Than you

  • @juneroyd.quinimon495
    @juneroyd.quinimon495 2 года назад +2

    Thank you for the video tutorial, it helps me a lot! keep up

  • @HelpingHands3838
    @HelpingHands3838 3 года назад +2

    Thanks for the explanation 👍
    One clarification needed...
    I own a repo called repo1 and it has a submodule called repo2. The repo2 has two files namely a.txt and b.txt . I want to create a new file c.txt in repo1 . I want to make sure the c.txt file should have the content of a.txt which is available under repo2 through submodule. How could I achieve this ? Any changes to a.txt in repo2 (in actual repo) also should reflect in my c.txt
    Hope I m not confusing... 😀

    • @RedhwanNacef
      @RedhwanNacef  3 года назад +2

      Anytime :) This depends on the tech used of course and exactly what you are trying to achieve. In general, if you need c.txt to contain content from the submodule, you could add a simple script that copies that content over. Then just run this script anytime you update the submodule. (or even a script that does both). Hope that helps, but if you are looking for something more specific let me know.

    • @HelpingHands3838
      @HelpingHands3838 3 года назад +2

      @@RedhwanNacef thanks mate 👍... that clarifies my doubt

  • @taylorfritz6648
    @taylorfritz6648 3 года назад +2

    This was so helpful! I do have a question though... I made a change in my submodule repo but the change never showed up in my parent repo. Is there where I need to explicitly ask git to go update to the latest commit in that submodule?

    • @RedhwanNacef
      @RedhwanNacef  3 года назад

      Thank you! Thats right (assuming you have committed and pushed the changes in the submodule). I usually "cd" in to the submodule from the parent repo and git pull from there, but you can also use the submodule commands from the parent directory and that should do the trick. 👍🏽

    • @taylorfritz6648
      @taylorfritz6648 3 года назад +1

      @@RedhwanNacef Thank you so much for responding! A little bit after I asked, I ended up figuring out how to pull in those changes and then push/commit those changes to the submodule as a part of the parent repo. You said it very clearly here too, to track exactly what I was doing! Thanks again! :)

    • @RedhwanNacef
      @RedhwanNacef  3 года назад

      Anytime 😊

  • @osys7832
    @osys7832 Год назад +1

    I’m not a git guru but to sum up
    - git submodule is a fancy name for submodules, they’re essentially just git projects
    - any commands u can use with your own git project can be used inside the modele projects(git push pull etc)
    - to recursively install submodules -recursive-submodules is necessary with git pull or clone
    - same thing goes for the git push as well

    • @RedhwanNacef
      @RedhwanNacef  Год назад

      You got it! The .gitmodules file is probably a good thing to remember too when summing up.

  • @sonnix31
    @sonnix31 Год назад +1

    Very nice, thank you

  • @belphegor6979
    @belphegor6979 2 месяца назад

    Thank you this was wery helpful

  • @maitreverge
    @maitreverge Год назад +1

    This is a precious video, thanks for clarifying this subject !

  • @vishekkumar3184
    @vishekkumar3184 2 года назад +1

    Hi Nice explanation!!! I have one query, if we initialize a sub-module so for which branch of sub-module project it is considered in the parent project?

    • @RedhwanNacef
      @RedhwanNacef  2 года назад

      Thanks! You can specify the submodule branch in the .gitmodules directory, if not it defaults to the remote HEAD (which basically means it defaults to the default branch). Hope that helps!

  • @eduardojreis
    @eduardojreis 2 года назад +1

    9:36 - Showing the branch in the command line prefix is very clever. How do you do that? Is that automatic? I am under anaconda, so I get to see the environment name, not the git branch name. Cheers,

    • @RedhwanNacef
      @RedhwanNacef  2 года назад

      I am using a shell called 'Zsh' with 'Oh My Zsh' will lets you configure/customise all of this. It's very useful.

  • @AlexSmith-fs6ro
    @AlexSmith-fs6ro 3 года назад +1

    Can you specify a submodule to reference a branch rather than a commit hash?
    The idea is to work on that submodule branch, ie new commits, push, pull/fetch, rebase. Then merge the submodule branch into, say, master.
    Can you specify a tag for the submodule?

    • @RedhwanNacef
      @RedhwanNacef  3 года назад +1

      I don't think you can, it will always reference a commit, however, you can specify a commit hash from a different branch. For example, you can specify a branch in the .gitmodules file and it will use the latest commit hash from the branch. You can still do the workflow you have specified, you will just need to make sure you use the right commit hash once merged. I don't you can specify a tag either, but again a tag will always be linked to a commit hash so I think you could use that commit. Hope that helps!

  • @kadiryumlu
    @kadiryumlu 7 месяцев назад

    Should I create a seperate repo for submodule?

  • @michaelakin766
    @michaelakin766 Год назад +1

    Great video. Question for you. I have a git repo that I need to break into different repos with submodules. Do you know of a way to do that and keep the git history for each new repo?

    • @RedhwanNacef
      @RedhwanNacef  Год назад +1

      Thanks. Not sure if there is an easy way to do that, I remember hearing about a project where this was done but it was all manual with cherry picking etc. There may be some tools out there that might help with this. Good luck!

  • @stephencovrig8373
    @stephencovrig8373 Год назад +1

    Awesome tutorial

  • @AjeetKumarSharma-z8k
    @AjeetKumarSharma-z8k Год назад +1

    Nice explanation.

  • @danielvega646
    @danielvega646 Год назад +1

    Neato! Amazing explanation, thanks a lot. Greetings from Colombia. Keep it up!

    • @RedhwanNacef
      @RedhwanNacef  Год назад

      Hello Colombia! Glad you enjoyed it 😊

  • @anuragchauhan5170
    @anuragchauhan5170 Год назад +2

    Very well done, awesome tutorial, clean and precise :)

  • @fredrikwaldt194
    @fredrikwaldt194 3 года назад +1

    You know the desciprition of the video could really use a short summary of the commands, so that i dont have to look for them. Great video thou!

  • @praveenkore842
    @praveenkore842 Год назад +1

    nice info brother

  • @lifeisbeautifu1
    @lifeisbeautifu1 5 месяцев назад

    Amazing, thank you!

  • @JuanPortalG
    @JuanPortalG Год назад +1

    Thanks, man!

  • @iambiswajitsahoo
    @iambiswajitsahoo Год назад +1

    Thank you very much for making this video ☺️

    • @RedhwanNacef
      @RedhwanNacef  Год назад

      Thank you very much for watching 😊

  • @MohammadhosseinMalekpour
    @MohammadhosseinMalekpour 3 месяца назад

    Great, thanks man.

  • @danumichael2143
    @danumichael2143 2 года назад +1

    Great video

  • @krisculin9679
    @krisculin9679 Год назад +1

    This was a very nice beginner's look at submodules. Thank you.

  • @l.243
    @l.243 2 года назад +1

    Thanks for the video, it explains the matter clearly.

  • @alexanderx7959
    @alexanderx7959 Год назад

    looks like pure man's package manager :)
    kidding, of cause, i can see a couple of usecases... but still :)

  • @patryktraczyk3246
    @patryktraczyk3246 3 года назад +2

    Really good explanation! Great video, thanks for it!

  • @import-ai
    @import-ai 2 года назад +1

    Brilliant explanation. Thank you so much!

  • @ivandimitryzyrianoff203
    @ivandimitryzyrianoff203 2 года назад +1

    Thanks for the video! It helped me solved a issue that I was struggling for a whole day

  • @thaynethetigerbarnes
    @thaynethetigerbarnes 4 месяца назад

    I think you helped me with a huge problem, I am trying to use strapi for my back-end and I have struggled getting it to commit in one repo I do believe this will be the fix! TY!

  • @karankundar7276
    @karankundar7276 Год назад

    Can i update multiple destination repositories with one source repository while executing some git submodules command at the source repository ?

    • @RedhwanNacef
      @RedhwanNacef  Год назад

      "git submodule update --remote" might be what you are looking for?

  • @ricardomonicat7564
    @ricardomonicat7564 Год назад +1

    Clean and usefull explanations. Thank you!!!.

  • @TyrboCreed
    @TyrboCreed 8 месяцев назад

    13:00 it is not the same commit hash when you click to the youtube-tutorials submodule.

  • @theneilpowers
    @theneilpowers 2 года назад +1

    Excellent tutorial. Answered all my questions and more.

  • @sameerakhatoon9508
    @sameerakhatoon9508 2 года назад +2

    this was lit, ty sm

  • @jadenataylor
    @jadenataylor Год назад +1

    Had to use this for work. Thanks for the video!

  • @dhivyadandapani7159
    @dhivyadandapani7159 Год назад

    Is your 'tree' command an alias?
    If yes, could you share the entire command for the alias?

    • @RedhwanNacef
      @RedhwanNacef  Год назад

      It is an alias for the tool 'exa' (an 'ls' replacement). The command I run is 'exa -T -L 2 --icons'.

  • @nikitakrasnytskyi
    @nikitakrasnytskyi 7 месяцев назад

    I just want to leave feedback here. I find your way of giving a material to be of very high quality. Compared to many others on learning platforms, you can give material fast and keep the essential pieces. Like, you only cover the most vital submodule commands. Really appreciate the way you teach. Saw this video and subscribed for more.

  • @tonyjaradev
    @tonyjaradev 2 года назад +1

    Also this is amazing for managing typescript between projects (I think, gonna try now) Thank you so much!

  • @gpeta42
    @gpeta42 Год назад +1

    Thank's you man 🤝, very useful

  • @tullee7228
    @tullee7228 Месяц назад

    Great video

  • @BrocchiRodrigo
    @BrocchiRodrigo 2 месяца назад

    I enjoyed the content! It helped me a lot with a project I'm working on with some colleagues.
    Very nice!

  • @projetoforum7685
    @projetoforum7685 2 года назад +1

    Thank you so much, excellent tutorial

    • @RedhwanNacef
      @RedhwanNacef  2 года назад

      You're very welcome, glad you liked it.

  • @danielcorzo7498
    @danielcorzo7498 2 года назад +1

    Great Video!! 👍👍 What if I'm cloning a third party tool that I'm not going to be making commits to, or very small changes at most? Can I just pull the commits to that repo?

    • @RedhwanNacef
      @RedhwanNacef  2 года назад +1

      Thank you! Yea the same approach can used with any repository as long as it is publicly accessible. Not sure if you have a specific use case in mind?

    • @danielcorzo7498
      @danielcorzo7498 2 года назад +1

      @@RedhwanNacef I was thinking about receiving any changes they make in their repo. I may not make any changes to that third party tool myself. Forvige me, I'm still a noob 🙈

    • @RedhwanNacef
      @RedhwanNacef  2 года назад +1

      Yea that makes sense. Git submodules should work fine for that. No worries, you will be a pro in no time!

  • @aravindmuniraj-l1f
    @aravindmuniraj-l1f Месяц назад

    clean and clear

  • @markrussell5587
    @markrussell5587 3 года назад +2

    that was great thanks

  • @charan775
    @charan775 Год назад +1

    best tutorial for submodule concept

  • @cthulhu7397
    @cthulhu7397 Год назад +1

    clearly explained, thank you

  • @erniepasveer8027
    @erniepasveer8027 3 месяца назад

    Clear and concise. Good presentation style and technique.

  • @rwboshae
    @rwboshae 3 года назад +1

    Very good tutorial, thanks.

    • @RedhwanNacef
      @RedhwanNacef  3 года назад

      Thank you and you’re welcome 😊

  • @eryks2269
    @eryks2269 2 года назад +1

    Good explanation, thank you.

  • @eric-ampire
    @eric-ampire 9 месяцев назад

    Great explanation

  • @LewisCampbellTech
    @LewisCampbellTech 2 года назад +1

    Good explanation. Last time I had to share a unit of in-house code between two projects I went with the internal NPM package, which was a bit of a nightmare to set up, deal with special keys etc etc. This would have been cleaner.

    • @RedhwanNacef
      @RedhwanNacef  2 года назад

      Thanks! Yea I have done the exact same thing before, always good to better understand the alternatives. 🙂

  • @Blast-Forward
    @Blast-Forward 3 года назад +1

    Thanks for the explanation.

  • @JimmyWorld
    @JimmyWorld 2 года назад +1

    Excellent explanation. Thanks.

  • @gregormurray314
    @gregormurray314 Год назад

    Thank you from a fellow scot, i am messing about with robot programming and need to share python and nodejs code between the code running on the robot and the code running on the desktop this gave me the overview i needed to realise that submodules were the elegant solution i needed. So many other options i have tried just gave me a major headache.

  • @refused_hc7882
    @refused_hc7882 8 месяцев назад

    Thanks for your time, totally helpful!

  • @MayureshKadu
    @MayureshKadu 11 месяцев назад

    Very useful and well explained. Thanks

  • @nicolasmenescardi4077
    @nicolasmenescardi4077 3 года назад +1

    great video. Thanks!

  • @jimbobear1812
    @jimbobear1812 2 года назад +1

    This guy rocks. Thank you!

  • @CoderHarsh
    @CoderHarsh 6 месяцев назад

    Thanks ❤

  • @Squirrelies1
    @Squirrelies1 9 месяцев назад

    Well presented, clear, and informative! Great job! Thank you. :)

  • @codeplausch
    @codeplausch 2 года назад

    I tried everything, but it doesn't work for the HUGO theme which I tried to adjust.

    • @RedhwanNacef
      @RedhwanNacef  2 года назад +1

      Sorry I don't understand the issue. If you can try explain the issue/point to me a repo I am happy to try take a look and help.

    • @codeplausch
      @codeplausch 2 года назад

      @@RedhwanNacef thank you. :) right now, I can't, but I will write you in a few days, what is happening. I can just say now that I cloned a HUGO theme into my repo according to the quick start instructions, then edited the theme and wanted to push the changes.

  • @azir8930
    @azir8930 Год назад +1

    ❤‍🔥

  • @luizcesarmerjandepaula6067
    @luizcesarmerjandepaula6067 3 года назад +1

    Nice! Thank you for the content

  • @blue_mustang_
    @blue_mustang_ 2 года назад

    how do I delete a submodule created by accident??

    • @RedhwanNacef
      @RedhwanNacef  2 года назад

      You should just be able to remove the .gitmodules file and all the submodule files and commit. (There may be some references in the .git directory to the submodule that you need to remove too) maybe try this: git.wiki.kernel.org/index.php/GitSubmoduleTutorial#Removal.

  • @Travel-2-chill
    @Travel-2-chill 2 года назад

    i am unable to access components from submodule

    • @RedhwanNacef
      @RedhwanNacef  2 года назад

      Any error message/repo you can share so I can try help?

  • @habibmosavi
    @habibmosavi 7 месяцев назад

    Very simple and clear, thanks man!

  • @hussainshaik4390
    @hussainshaik4390 2 года назад +1

    wow simple and yet all i needed

  • @udaykumar-tb5kn
    @udaykumar-tb5kn 2 года назад

    Bit slow pls... Not everyone can understand your slang and phase of voice