Also, for build systems where you want the build to always track the production branches of various projects, update –remote gives you a convenient way to update the build tree. Normally, this would have to be documented elsewhere, or figured out in some other way. gitmodules and quickly determine that submodule X is tracking branch Y. gitmodules functions more as documentation and convenience. The same thing could be accomplished with something like git foreach “git fetch & git checkout test”. In the actual repository, Git still stores submodules pointed to a particular commit. This functionality is purely a convenience feature in the submodule update command. Now, if you run git submodule update –remote, Git will update the meta-bec submodule to the latest on the test branch. If you want a different branch, simple edit. So, if you already have a Git submodule set up, its a simple matter to run git submodule update –remote to update the submodule to the latest master branch. The only alternative solution I know of now is to run git submodule foreach -recursive git fetch -tags before git submodule update -recursive, which just makes things harder than they should be. If you don’t want to fetch, you should use submodule update –remote –no-fetch. The release tags are not part of any branch, so if a git submodule refers to the commit of a release tag, it will be unable to check it out. In order to ensure a current tracking branch state, update –remote fetches the submodule’s remote repository before calculating the SHA-1. However, it does not update the submodules. For example, submodule update –remote –merge will merge upstream submodule changes into the submodules, while submodule update –merge will merge superproject gitlink changes into the submodules. By default, the git pull command recursively fetches submodules changes, as we can see in the output of the first command above. 1 day ago &0183 &32 After some work, I realised that my changes do not fit entirely in the scope of this project and I want to separate a new folder I created into a new git repo, while adding what remains to projectA as a submodule in the new repo. The only change is the source of the target SHA-1. This works for any of the supported update procedures (–checkout, –rebase, etc.). git/config (with .git/config taking precedence). The remote branch used defaults to master, but the branch name may be overridden by setting the submodule.branch option in either. The remote used is branch’s remote (branch.remote), defaulting to origin. Instead of using the superproject’s recorded SHA-1 to update the submodule, use the status of the submodule’s remote tracking branch. This option is only valid for the update command. The “ git submodule update –remote” command is the key to tracking branches with submodules. However, Git submodules are still not as flexible as Google repo, but since submodules are built into Git, the submodule command is a good solution in many cases. This is good news as in many cases, this is exactly the behavior we want. To get the latest version of a submodule, in the Submodules dialog box, click Fetch. As of version 1.8.2, Git submodules can now track branches instead of specific commits.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |