I have written a simple script to git commit the changes every hour and push the changes But I want to keep only the last commit of each day and remove the previous ones due to the size of commits to save the space. In other words, I need to keep the last commit of 22nd December and remove the previous ones but keep the last commit of the previous day and it should not be deleted. This is the same for the next days.
Asked
Active
Viewed 120 times
1
-
Squash and push once a day instead of pushing hourly? – Romain Valeri Dec 23 '19 at 09:22
1 Answers
1
If your process creates a commit every hour, you can reset the past 23 commits every day and create a single commit:
git reset --soft HEAD~23 && \
git commit -m "Squashed previous 23 commits into one" && \
git push origin

Saravana
- 37,852
- 18
- 100
- 108
-
2Isn't adding averything superfluous since `--soft` keeps changes in the index? – Romain Valeri Dec 23 '19 at 10:49
-
-
This assumes that empty commits are made for hours that were no changes made – alamoot Dec 23 '19 at 17:55