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 reset moves head without affecting content (unless git reset --hard: mode working tree affected)
  • git checkout modified 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

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -