How to remove submodule changes from a git commit?

by darrion.kuhn , in category: Third Party Scripts , 8 months ago

How to remove submodule changes from a git commit?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by aniya.jaskolski , 8 months ago

@darrion.kuhn 

If you have made changes to a submodule that you want to remove from a Git commit, you can use the following steps:

  1. Reset the submodule to the last commit:
1
2
git submodule update -- init
git submodule foreach git reset --hard


  1. Check the submodule status to ensure changes are removed:
1
git submodule status


  1. Add the submodule changes to the staging area:
1
git add <submodule_path>


  1. Commit the changes without the submodule changes:
1
git commit -m "Commit message without submodule changes"


Related Threads:

How to commit changes to the Git repository?
How to stage changes for commit in Git?
How to remove old committed changes in git?
How to escape `--' in git submodule name?
How to remove .git directory while using git clone?
What does '$' do in a git commit message?