What is the point for git reset accepting paths as an argument when we have git checkout? -
i understand git reset updates index, whereas git checkout updates working copy. don't understand use case requires git reset accept argument reference , path? seems want use git checkout in case?
this comes time when folks ask why can't git reset some-ref --hard -- some/path/to/file. real question why git reset accepts git reset some-ref -- some/path/to/file when have git checkout.
never thought of till teaching difference between two.
typically, if add file index, , realize want remove index, need:
- a reference (head) reset file index head (since head reference state nothing has been staged yet: commit)
- a file
that is:
git reset head -- a/file that "unstage" file.
git resetmoves head without affecting content (unlessgit reset --hard: mode working tree affected)git checkoutmodified working tree (and file content)
git reset accepts ref , path because has three modes (soft, mixed , hard).
(see "practical uses of git reset --soft?")
--hard mode similar git checkout.
more on same topic in "what's difference between 'git reset' , 'git checkout'?".
Comments
Post a Comment