~/src//anaulin/parent-repo (master) $ git submodule update -init -recursive # Initialize the contents of child-repo by updating the submodule: # Local copy of child-repo directory is empty ~/src//anaulin/parent-repo (master) $ ls child-repo/ Remote: Total 17 (delta 4), reused 12 (delta 2), pack-reused 0 Remote: Compressing objects: 100% (13/13), done. This command will get you a local copy of the submodule: ~/src//anaulin $ git clone into 'parent-repo'. ![]() Time you’ll need to additionally run git submodule update -init -recursive. When a project is set up with submodules, to clone and pull it for the first In order to have parent-repo be aware of those changes, use git submodule update -remote as well. You can also work on child-repo from outside of parent-repo in the usual Specific commit, instead of the latest one.) Options you can pass to git submodule -update if you ever want to update to a Parent-repo expects, using git submodule -update remote. We can get rid of this discrepancy by updating the commit of child-repo that This is git telling us that parent-repo expects its submodule to be at aĬertain commit, but the local version of the submodule is now at a different ~/src//anaulin/parent-repo (master) $ git diff No changes added to commit (use "git add" and/or "git commit -a") " to discard changes in working directory) ~/src//anaulin/parent-repo (master) $ git status move out of child-repo, into a different part of parent-repo. Now in parent-repo we see a diff: ~/src//anaulin/parent-repo/child-repo (master) $ cd. This git push will push the changes to your child-repo remote (because youĪre performing these operations from within the child-repo part of ~/src//anaulin/parent-repo/child-repo (master) $ git push ~/src//anaulin/parent-repo/child-repo (master) $ git commit -m 'Commit to child-repo' ~/src//anaulin/parent-repo/child-repo (master) $ vim README.md To edit a file from child-repo when working within parent-repo, you can work in the child-repo directory in the same way as if you were in a regular repo: ~/src//anaulin/parent-repo (master) $ cd child-repo/ Operating on files in parent-repo, works in the usual way: edit, commit, push, Working with files in parent and child repos We now have the files from child-repo available locally: ~/src//anaulin/parent-repo (master) $ ls child-repo/ If we do a git commit and push this to GitHub, we can see that GitHub now recognizes that parent-repo has child-repo as a submodule:Ĭlicking on the child-repo directory on this GitHub page takes you out of parent-repo and into child-repo at the specified commit. ![]() gitmodules file lists the submodules of the parent-repo, and which directory each module is mapped to: ~/src//anaulin/parent-repo (master) $ cat. ![]() Your branch is up to date with 'origin/master'. ![]() gitmodules file, and a new child-repo subdirectory: ~/src//anaulin/parent-repo (master) $ git status If we check the git status of the parent repo, we can see that this command has added a new. To begin, we need to add the child repo as a sub-module of the parent repo, and tell git in which subdirectory of parent-repo do we want the child-repo code to live: ~/src//anaulin/parent-repo (master) $ git submodule add child-repo When you make changes to child-repo, if you want those new commits to beĪvailable in parent-repo, you will need to additionally update parent-repo to In one tree, you can test and develop on both repos “together”. Way to make one atomic commit to both simultaneously. Because these are still two separate repositories, there is no Parent-repo will contain code from both repos, and you will be able to makeĮdits and track changes in both repositories.įor every commit, you’ll have to decide if you’re modifying child-repo or (let’s call it parent-repo) and adding the source of a second repository When you’re working with a git submodule, you are starting with a one repository These are my notes on the basics of working with Wanting to maintain a Hugo theme together with the actual Git submodules are a useful tool when you need to work on two closely coupled source AugUsing Git submodules to work on two repos at the same time
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |