Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens to a modified file when using "git checkout"?

I was simply trying out a few things on a project and wanted to delete some modified files I was working with but no longer needed.

I got careless and typed git checkout file instead of git checkout -- file. So essentially I was just checking out this modified file and I have no clue where that modified file went off to.

I've tried using git update-index --fresh just to try and see where this modified file could have gone but it seems like it may have been deleted in the end?

    modified:   test/ssc_test/cmod_tcsdirect_steam_test.cpp
    modified:   test/ssc_test/cmod_tcsfresnel_molten_salt_test.cpp
    modified:   test/ssc_test/cmod_tcsmolten_salt_test.cpp

These were the files I was trying to get rid of but forgot to add the -- to get rid of one of the edited files.

After checking out this file, instead of deleting it, it gave me the message, Updated 1 path from the index and it was no longer displayed along with the other modified files when using git status.

I'm pretty clueless with what happened exactly. Was it was deleted or hidden somewhere in the index, or something else?

like image 544
finnahuss Avatar asked Aug 14 '19 17:08

finnahuss


1 Answers

I got careless and typed 'git checkout file' instead of 'git checkout -- file'

Those commands do the same thing, unless for some reason teh actual name of file could be confused with a non-path argument to checkout.

Or to say that differently - the only thing -- does is to separate paths from other options in case it's ambiguous

like image 57
Mark Adelsberger Avatar answered Oct 11 '22 19:10

Mark Adelsberger