Reputation: 85
If i have a GIT repo where a number of edits have been done without commits, how can i best deal with that?
I could add files based on modified-date.
I can list all files by edit-date as described here: git status - list last modified date
But
git add
command?Upvotes: 0
Views: 415
Reputation: 13627
You can use a typical find | xargs
construct:
# up to 2 days (48 hours) ago
find . -type f -mmin +2880 -print0 | xargs -0 git add
git commit
# up until yesterday (24 hours ago)
find . -type f -mmin +1440 -print0 | xargs -0 git add
git commit
# all the rest
git commit -a
-mmin
takes the number of minutes, prepend the number with a +
to say "more than that". If your edits have been separated by days, you can use -mtime
instead because that takes the number of days, which may be easier to count than the number of minutes.
Insert commits for deleted files as appropriate. There is no way to tell when they were deleted, though.
Of course, this will be useful only if all edited files are independent. If a file has been edited twice, and the change after the first edit should have been committed, you are screwed because you do not have that state anymore.
Upvotes: 3