When are changes locally merged with `git checkout`? -


  1. suppose on master branch. there file in working directory called "master.txt" contains single text line "asdf".

  2. suppose git checkout f364f96d34fb2af20dbd8cccd91a83a1e277bcfe, takes me older commit on master branch head.

  3. i edit file "master.txt" (which still, @ point, has line "asdf") deleting line "asdf".

  4. i git checkout master.

  5. it appears master.txt still empty (i.e., no "asdf)!

question: way things supposed work? reading textbook on git, thought changes locally merged on git checkout if no conflicts arose. deleting "asdf" creates conflict, no?

when checkout commit without specifying paths, working tree updated match contents of tree of commit, current index (cache/staging area) left unchanged.

what see extension of behavior: if don't add change index, git reapply on top of new working tree don't lose it.

you can checkout head path of file remove change, or add index , commit it.

the reference documentation mentions "conflicts" occur if have local modifications on file different in trees of head , of target commit. in case, both versions of master.txt file contain asdf, working tree has empty. hence, there no conflict.

if add commit master.txt containing foo, checkout commit master.txt having asdf , same operations described, git prevent subsequently checking out second commit again.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -