What goes wrong when using git worktree with git submodules

Commit a83a66a is quite clear about that: git-submodule.sh expects $GIT_DIR/config to be per-worktree, at least for the submodule.* part. Here I think we have two options: either update config.c to also read $GIT_DIR/config.worktree (which is per worktree) in addition to $GIT_DIR/config (shared) and store worktree-specific vars in the new place, or update git-submodule.sh to read/write … Read more

Using someone else’s repo as a Git Submodule on GitHub

Yes, you can add any repository as a submodule in your project. Just do: git submodule add git://github.com/whomsoever/whatever.git … in the top level of your repository. This is indeed the easiest way with git to use some existing useful repository within your own. For more information on submodules, you could look at: Pro Git’s section … Read more

Git submodule URL not including username?

If I understand correctly, you’re using HTTP basic authentication over HTTPS to allow only particular developers to access the repository. In that case, you can commit a .gitmodules that looks like: [submodule foo] path = sub/foo url = https://example.com/git/foo.git … i.e. without a user name, and then tell each developer to put their username and … Read more

‘git submodule update –init –recursive’ VS ‘git submodule foreach –recursive git submodule update –init’

git submodule update –init –recursive The submodule update command will recurse into the registered submodules, update and init (if required) them and any nested submodules within. git submodule foreach –recursive git submodule update –init foreach will evaluate the command in each checked out submodule. So it will update and init (if required) each submodule and … Read more

Continue looping over submodules with the “git submodule foreach” command after a non-zero exit

Just make your command always return a 0 code like so: git submodule foreach ‘npm install || :’ This is taken from the manual: git help submodule: foreach Evaluates an arbitrary shell command in each checked out submodule. The command has access to the variables $name, $path, $sha1 and $toplevel: $name is the name of … Read more

git submodule update –remote vs git pull

The difference is: git pull will only update your submodule branch, but it can be any branch that you could have checked out yourself in that submodule repo. git submodule update –remote will only update the branch registered in the .gitmodule, and by default, you will end up with a detached HEAD, unless –rebase or … Read more

git submodule update vs git submodule sync

update is basically doing git pull in each submodule (except without a branch, since the main repo specifies a commit directly). The tricky one is sync. Imagine you clone a project with submodules, then later the upstream project changes one of the submodules to point to a different URL. Your local copy of the submodule … Read more