0

We decided to use git locally but had to test code on a server so we ended up having hundreds of test commits in git. How can we delete these test commits?

We have tried to delete them manually, but it is taking too much time.

sangi
  • 1

2 Answers2

0

From my knowledge of git, the impact of having many commits is negligible.
But you can try git squash if you are annoying having too many meaningless commits.
Refer to this answer How do I squash my last N commits together?

QSBK
  • 44
  • 4
0

My approach would be cloning the commits I want to keep to a new repository instead of deleting what you don't need anymore. You then can keep the old repo as a back-up or delete it.

MathijsG
  • 17
  • 6
  • 1
    Since commits are immutable, unless unreachable, the OP can always keep a branch pointing to the "old" commits. Then they can always be recovered. No need for a backup repo. – evolutionxbox Mar 23 '23 at 19:20