I have a Git Submodule on one of my project and I'm trying to update it on my local copy where I have made some changes. I want the remote to override my local changes, but when I tried the following command, nothing happens and I still see my local changes in place.
joesan@joesan-S-14-v5:~/Projects/Private/github-docs/joesan-me/themes/hugo-clarity$ git status
HEAD detached at d5800ff
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: exampleSite/config/_default/params.toml
no changes added to commit (use "git add" and/or "git commit -a")
joesan@joesan-S-14-v5:~/Projects/Private/github-docs/joesan-me/themes/hugo-clarity$
What is that I'm doing wrong here?
CodePudding user response:
As @torek comment says, git status
is only show you the current status of your git repo. It will not do anything.
You can't simply use git reset --hard
when you at super repo root. You should cd
into submodule before reset
, checkout
or restore
.
So:
cd path/to/submodule
git reset --hard # or git restore .
if there are many submodule or you don't want to cd
into it, you can use:
git submodule foreach git reset --hard
but this will effect all submodule under super repo, be aware!