Git add remote submodule
To tell git that changes in the submodules (no matter whether you committed them locally or pulled) should be part of the repository that you are working, you have to add and commit these changes.įor this, you simply add the submodule folder to your index like any other folder that contains changes that you want to commit: This means that pulling submodule updates only affects your local copy. This great power also comes with an additional responsibility: As long as you don't tell git that you want your repository to depend on a new version of a submodule it will keep the old version. (If you want to rebase instead of merging, you should read the section on submodules in the "Pro Git" book!)Īdd and commit submodule changes (local or pulled)Īs stated in the intro, git submodules have an important advantage over svn externals.
#Git add remote submodule update#
Merge submodule changes before committing and pushing them git submodule update -remote -merge Prosuming submodule changes change and commit in submodules
![git add remote submodule git add remote submodule](https://blog.sourcetreeapp.com/files/2013/12/pull-subtree-blog.jpeg)
Therefore, it's best to simply always checkout directly after cloning a submodule.) (If you don't do this before changing stuff, then you have to merge with a branch as soon as you want to push local commits. To locally get all changes that were done in submodules:īefore producing submodule changes checkout a branch for a submoduleīefore you start to change something in a submodule you have to checkout a branch in the submodule folder:
![git add remote submodule git add remote submodule](https://i.stack.imgur.com/8a73P.png)
Please share it with your fellow developers and colleagues.Working with existing submodules consuming submodule changes pull upstream changes of submodules I always check for new comments and respond/answer to them. If you have any questions please ask them in the comments section. I have written more tutorials on git if you are interested in learning more about it and its commands. To add a submodule use: git submodule add.As you can see, Git makes it easy for us to manage submodules by providing simple-to-use commands.
#Git add remote submodule how to#
Rename your submodule's folder again: bash mv submodulefolder_tmp submodulefolder Final thoughtsĪlthough submodules aren't the most well-known feature of Git, developers need to know when and how to use them. Remove the folder using the git rm cached command: bash git rm -cached submodulefolderĤ. De-initialize the submodule: bash git submodule deinit submodulefolderģ. Rename your submodule's folder: bash mv submodulefolder submodulefolder_tmpĢ. To remove a submodule but keep the files you need to follow those steps:ġ. Remove the config with: bash git config -remove-section How to remove a git submodule but keep the files?
![git add remote submodule git add remote submodule](https://media.vlpt.us/images/wnduq8/post/cee8e4ff-1836-4d06-b795-f1d51fb47f67/image.png)
Remove the submodule folder with: bash rm -rf. If you want to remove those references as well you need to follow those steps:ġ. git folder will be kept around to make checkouts of past commits possible. Also, it will remove the submodule folder. Then you will need to commit and push the submodule. To verify that the command worked use the git status command.
![git add remote submodule git add remote submodule](http://i.stack.imgur.com/01PNT.png)
gitmodules file with the submodule entry and the submodule folder. To add a submodule to a repository use: bash git submodule add To remove a submodule first, we need to add one to our repository. How to remove a git submodule but keep the files?.