1

Occasionally I want to change my git working copy to a pristine state. I do this with the following two commands:

git clean -dxf
git reset --hard

Is there any reason to run clean before or after reset? No matter what kind of crazy situation I have got my repo into, could running them in one order or the other ever fail or not get me back to where I want to be, as if I had a clean checkout?

Might I ever need to do something even more complicated like clean-reset-clean?

1 Answer 1

1

Is there any reason to run clean before or after reset?

Yes. git clean responds to the state of the index. git reset --hard changes the state of the index. So git clean needs to be run after the index state is corrected, which is what git reset --hard does.

Might I ever need to do something even more complicated like clean-reset-clean?

No.


Note: This answer is not intended as an endorsement of saying git clean -dxf. It merely responds to the specific question on its own terms.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.