friartuck
friartuck

Reputation: 3121

Touch all files in a git repo so git thinks they are changes

I need 'touch' (I think) all files in my git repo (lots of files) so that running git status will have them as modified (and then I can add and commit them). I need to do this because our in-house tool uses the files from a git commit to generate a report ... which I've been asked to do

In posix environments I think I could just touch a directory and go from there.

Upvotes: 6

Views: 4392

Answers (3)

Philippe
Philippe

Reputation: 31177

I don't think that's possible because git detects a file change by determining if the content of the file changed. Touching the file will have no effect (even on unix).

Perhaps changing the permission on the file could be a very dirty solution but I'm not even sure of that and that's if you find a new permission that don't introduced some bad side effects!

The better solution is to update your reporting tool. And being obliged to commit changes for ALL files to trick your tool and dirty your history is in my opinion a very bad idea...

Upvotes: 4

Brad Parks
Brad Parks

Reputation: 72101

I had a demo repo that had a bunch of files in it, that had commit messages that I didnt want showing up in the demo - and to be clear, the repo was "garbage", in that it was just basically a dump of files to demonstrate a folder structure.

That having been said, one way you could do this is to

  • create a new temporary folder in your repo, for example "ez"
  • move all the files of the repo into it, e.e. "$ mv * ez"
  • commit that locally, the do the reverse and move them out again
  • "$ mv ez/* .; rmdir ez"

That would show all files as having been changed. For my purposes, I then committed that change too, and pushed it up to my demo repo.

Upvotes: 0

David Neiss
David Neiss

Reputation: 8237

If you were asked to "generate a report with all files" does that mean list all files in a commit? Cause that's easily done with something like a git ls-tree -R HEAD

Upvotes: 0

Related Questions