When are changes locally merged with `git checkout`? -
suppose on master branch. there file in working directory called "master.txt" contains single text line "asdf".
suppose
git checkout f364f96d34fb2af20dbd8cccd91a83a1e277bcfe
, takes me older commit on master branch head.i edit file "master.txt" (which still, @ point, has line "asdf") deleting line "asdf".
i
git checkout master
.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
Post a Comment