I'm following Git tutorials but I'm still not very clear about the Pull command and the effects on the remote and local repositories.
My two questions are the following:
Q1: Let's say I have a project with submodules 1 2 and 3, the local and remote repos are up to date. Now, a teammate changes submodule 3 on the remote repo. So now, the remote will be ahead by one commit.
Q2:
If I then go into my local repo and Pull, will extra files on local be deleted so that it is up to date with what's on the remote, leaving a total of just three files?
Thanks
will it overwrite whatever is on my local repo with that information?
It will update but not necessarily overwrite the content in your submodule 3 directory. If you have no local modifications, yes then git pull
will update all files updated remotely. If you should have any files modified you will get a conflict (can be mitigated with git pull origin --rebase
). In other words there is nothing special with this submodule repository, git pull
behaves the same as everywhere.
Where there is a difference though is that after you do a pull inside the submodule it will be marked as updated and dirty in the parent repository but it will not make any changes to the version it is linked to. To do that you need to explicitly from the parent repo do git add submodule3dir; git commit -m "Updated submodule 3 to latest version"
.
In other words git pull inside a submodule will update your worktree, but it will not update your index and it will not create a corresponding commit. You need to explicitly run add
and commit
to do that.