0 votes
1 view
in Devops and Agile by (20k points)

When I run git reset --hard HEAD, it's supposed to reset to a pristine version of what you pulled, as I understand it. Unfortunately, it leaves files lying around, as a git status shows a big list of untracked files.

How do you tell git "Just bring it back to EXACTLY what was in the last pull, nothing more, nothing less"?

1 Answer

0 votes
by (28.4k points)

First, you have to use git clean -f -d to get rid of untracked files and directories in your working copy.

If you need to reset the whole repository to master including all git submodules, run this script:

git reset --hard HEAD

git clean -f -d

git checkout master

git fetch origin master

git reset --hard origin/master

git pull

git submodule update

git submodule update --init --recursive

git submodule foreach git reset --hard HEAD

git submodule foreach git clean -f -d

git submodule foreach git submodule update --init --recursive

git submodule foreach git fetch

git submodule foreach git pull

git status

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...