Reputation: 88528
There's something that I want. I'm hoping it exists, and if it doesn't I might create it. I'll describe it, and if you know something like that please let me know. If not and you have any pointers on how to create it, I'll appreciate that too.
I've been using Git for my projects for years now, but only now I started working in a big company on a repo that ~100 developers commit to. When I was working alone and in small teams, I've gotten used to making lots of commits all the time, staging all the files, and using an empty commit message (yes, that's the way I roll.) I basically used commits as an extended save operation; whenever I typed a non-trivial amount of code, I committed it all and pushed to a non-master branch.
Now that I work in a big company I can't do that, because it'll be a nuisance to the other people. So I still do frequent, undocumented commits, but when I'm done I squash all of them by rebasing, give them a nice informative commit message, and send a merge request with just that commits. All my interim commits will be deleted on the next garbage-collection run.
I don't like how all my interim commits are deleted. They may be ugly, but I love them. Sometimes they have bits of code that I've written and then deleted, and I don't want to lose that code. Maybe I'll need it again in the future.
Now, I could put all of these commits on a private branch. But it'll be a nuisance to create and maintain such a set of branches. Because it means that every feature branch will now need another auxiliary branch that'll stay open and unmerged forever. Yuck.
What I want is a system that saves any commit made in Git and ensures it'll stay accessible for the foreseeable future. It's important to me that this will be automatic, without needing to take any action. I want to know that I can go back to any commit I made, even if it was lost in a squash.
Does something like this exist? Any pointers to creating it?
Upvotes: 4
Views: 33
Reputation: 1323523
One possible idea would be to setup a post-commit hook which would push each created commit to a dedicated repo.
That push would be using the current branch or, if the push is rejected because of a non-fast-forward push (the branch has been rebased/rewritten), to the "current_branch_1" (_2, _3...) in order to keep the old history previously pushed unchanged.
That way, you keep using your current repo the normal way (with rebase/reset which can eventually loose commits once the reflog is purged).
Yet, each commit ever created is still visible in that "archive" repo.
Upvotes: 1