github - git checkout olderversion but now checking what version is being used -
i have file, lets say, test.txt. lets empty file , committed it, first commit empty file. lets sha 2d37f7
now lets edited file , added text "hello world" in file , committed file. have hash hello world version , lets that hash eec1598
now when git log, see this
eec1598 (my last commit on top) 2d37f7 (my first empty file)
now lets want go first file, this
git checkout 2d37f7 test.txt
when check file, empty , good. when
git log test.txt
it shows me same thing above
eec1598 (my last commit on top) 2d37f7 (my first empty file)
at point don't know version of test.txt current version. how find out?
thanks
note shas shown in git log
commits, not file. asking how determine commit current working copy of test.txt came from. unfortunately, information not stored anywhere. in cases, there no single commit can file came from, file have same contents in multiple commits.
so in summary, after git checkout <sha> <filename>
, git considers working copy of filename
other file have locally changed; not tied particular commit.
now, being said, can hash of current version of test.txt git hash-object
, pass hash script lists commits contain version of file. see couple examples of kind of script see first answer this question.
Comments
Post a Comment