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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -