tags:

views:

69

answers:

5

Is there a single command that automatically regenerates a git repository?

I want to not just automatically add and update files that I've manually created or updated in my file system (as would git add .), but also to automatically delete files from the repository that I've manually removed from the app in my file system (something like git add_or_delete .).

I'm tempted to try a new git init but I've avoided this so far in case it has unexpected side-effects.

For troubleshooting purposes, I need the command to not just scan my file system for changes to apply, but to actually build the repository again from the version of the app in my filesystem.

A: 

git commit -a will add all new files and delete all removed files; but it's not clear if that's the answer to your question

AlBlue
Thanks. Yes, the file that I can't git rm is still in there somewhere. Need to go rebuild. Cheers.
steven_noble
A: 

Based on the git-hg rosetta stone, git add .; git ls-files --deleted | xargs git rm sounds like it might work (it is supposedly the equivalent of hg addremove, which sounds like what you want).

Hank Gay
Cheers. I'll try that next time I run into this need.(Can't test it now as a colleague just fixed the problem by removing the individual file at fault.)
steven_noble
A: 

If I undrestood your question correctly:

git commit -a will only commit all changed and deleted files, for new files you also need to specify git add .

Thus:

git add .
git commit -m "New structure" -a

does the trick.

Timo Metsälä
+2  A: 

git add -A stages all (un)tracked content to the index. So, anything git knows about that is modified will be ready to commit and all new files that exist in the working directory will be added.

jamessan
Which version of git has that? My 1.5.6.4 hasn't heard of it :-(
Timo Metsälä
It was added in 1.6.0.
jamessan
+1  A: 

git add -A will update known files, remove deleted files, and add new files.

Esko Luontola