I have a git submodule (RestKit) which I have added to my repo.
I accidentally changed some files in there and I'd like to go back to the source version. In order to do that, I tried to run
Mac:app-ios user$ git submodule update RestKit
But as you can see here, this did not work as it is still "modified content":
Mac:app-ios user$ git status ... # modified: RestKit (modified content)
Even
Mac:app-ios user$ git submodule update -f RestKit
doesn't revert locally modified files.
How do I reset the content of that submodule?
The submodule is just a separate repository. If you want to make changes to it, you should make the changes in its repository and push them like in a regular Git repository (just execute the git commands in the submodule's directory).
Once you have set up the submodules you can update the repository with fetch/pull like you would normally do. To pull everything including the submodules, use the --recurse-submodules and the --remote parameter in the git pull command .
Just cd into the submodule's directory and: git add -A git commit -m "some message" git push Then cd to the main repo and do the same.
In order to add a Git submodule, use the “git submodule add” command and specify the URL of the Git remote repository to be included as a submodule. When adding a Git submodule, your submodule will be staged. As a consequence, you will need to commit your submodule by using the “git commit” command.
If you want to do this for all submodules, without having to change directories, you can perform
git submodule foreach git reset --hard
You can also use the recursive flag to apply to all submodules:
git submodule foreach --recursive git reset --hard
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With