![]() ![]() ![]() However, that’s often not what you want – there’s a good chance you’ll want a different commit message for the submodule change. Mercurial actually requires this, by default it automatically commits subrepository changes when you commit the parent, using the same commit message. If you have write access to the upstream submodule source (and if not, maybe you might fork it and change the submodule source, see below), you may sometimes update files in the submodule, and want to commit / push those changes at the same time as you commit / push changes to your parent repository. Once you have done this, return to the parent repository and you will see an uncommitted change on the submodule, which will show in the diff the change in tracked commit:Īgain, you commit & push this change just like any other, after which point the submodule contents will be pinned at this new commit.Ĭommit / push changes to a submodule together with parent repository If there are new changes in the submodule which you want to use in your repository, all you have to do is open the submodule (double-click) and checkout/update to a different commit, either via pull, merge or just manually checking a commit out – just as you would do normally with any other repository. Submodules are pinned at a given commit, so that you always get the expected version of the submodule contents. Submodules are likely to be more static than your own main repository, but there are still several tasks related to them that you may want to do:Ĭhange the submodule commit which your repository is tracking Once you’ve done this, anyone cloning the repository will also get the submodule, at the same commit. ![]() These uncommitted changes represent the addition of the submodule to your repository, and you must commit & push them as you would do with any other change. In Mercurial, there will be a “.hgsub” file instead but the principle is the same. You’ll see in the file status view that a couple of entries have been staged: In this case you’ve just added the submodule, but it’s not actually committed yet. ‘…’), or incoming / outgoing changes (up/down arrow). Submodule entries can also have annotations to let you know if there are uncommitted changes in the submodule (ellipsis annotation, i.e. If you wanted to see more detail about the submodule, just double-click on it to open it in its own repository window, from which you can, if you like, make changes to it just like any other repository. This tells you that your submodule is located in dependencies/sub1 and is currently on the ‘master’ branch. Once the submodule has cloned, you’ll see it appear in the sidebar like this: You’ll then be prompted to provide a source URL to clone the contents from, and the path within the current repository that this submodule will reside. Adding a submodule to your projectĪdding a new submodule to your project is simple, just right-click on a blank area of the sidebar and select ‘New Submodule’ (or select it from the Repository menu). The most common reason for wanting to do this is that your project has dependencies on other code bases (libraries for example), and you want to track those from their original sources rather than duplicating the files within your own repository.įor the sake of brevity from here on I’ll use the term ‘submodule’ to mean ‘subrepository’ as well, unless I’m talking about a Mercurial-specific feature. The terms may be different, but they refer to the same concept that of nesting other repositories within the folder structure of your own repository. That might be not so easy to solve so i strongly recommend you to stash your changes before doing 'pull'.Using submodules and subrepositories By Steve on February 1, 2012Ī headline feature of SourceTree 1.3 is the support for submodules (in Git) and subrepositories (in Mercurial). If you didn't stashed, you will probably get conflicts now, because the system is not smart enough to know whats the priority: what you have changed or what people from other branches changed. Pull things people updated on your head branch using git pull origin branchName Reseting your commits, but keeping the changes by using git reset -soft HEAD^ People probably have made updates into the project you've cloned (that explains the commits behind) and you've also made commits since you've cloned, and didn't pushed yet (and that explains the commits ahead). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |