开发者

Regenerate a git repository

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.


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.


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


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.


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


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜