OT: git question -- fetch a deleted file?

Sean seanlkml at sympatico.ca
Thu Oct 5 14:31:58 PDT 2006


On Thu, 5 Oct 2006 12:49:55 -0500 (CDT)
"Jeremy C. Reed" <reed at reedmedia.net> wrote:

> I used "git-reset HEAD" to tell me the filenames of which files were 
> missing ("needs update"). I don't know if that is the correct way.

"git status" will show you all the files you have deleted as well as
the uncommitted state of any locally edited files etc.  To see just the
files you have deleted, use "git ls-files -d".

> Is there a way to get it to replace my missing files without me doing each 
> file at a time (like "cvs up")? (It doesn't seem like I should parse 
> git-reset output to be reused by git-checkout for this.) I see 
> git-checkout -f but I don't know if that will overwrite my changes. I just 
> want to replace all my missing files.

Git sees your deletion of a tracked file as an uncommitted change, just
like any other (ie. no different than an edited file).   Now Git will
allow you to pull or merge in any upstream updates as long as they
don't conflict with any of your uncommitted changes.  So you _can_ update
the branch and your working files before committing your local changes.
But Git has no way to know that you want it to un-delete files at the
same time.

"git reset --hard" will return your working files to match HEAD, and thus
replace all the files you deleted.  _However_, it would mean you lose
*ALL* uncommitted changes in your working tree as well.

You could use  "git ls-files -d | xargs git checkout --" to restore just
the deleted files.

HTH,
Sean



More information about the xorg mailing list