I don't really fault the junior dev who does that. They are just following the "I don't understand something, so just start over" paradigm set by seniors.
I don't really fault the junior dev who does that. They are just following the "I don't understand something, so just start over" paradigm set by seniors.
If you have proper observability in place then you can do your diagnosis without affecting your customers.
Plus, at the same time successful diagnosis is also the kind that can have the most dramatic effect on your customers.
In a positive way.
A special case of this is git rebase after which you "can" access the original history in some obscure way until it's garbage-collected; or you could clone the repo before the merge and then you can access the original history straightforwardly and you decide when to garbage-collect it by deleting that repo.
I would never ridicule anyone for your approach, just gently encourage them to spend a few mins to grok the ‘git reflog’ command.
- Commit any pending changes.
- Make a git tag at your current head (any name is fine, even gibberish).
If anything “goes wrong” you can rollback by simply doing reset hard to the tagged commit.
Once done, delete the tag.
Making a complete “backup clone” is a complete waste of time and disk space.
The two primary source code management activities developers use are versioning of source code (tracking changes which happened over time) and the other being synchronisation of code with other developers.
One of Git’s differentiating strengths is it being decentralised, allowing you to do many operations in isolation locally without a central server being involved. You can then synchronise your local repository with an arbitrary number of other copies of it which may be remote, but you may need to rebase or merge in order to integrate your changes with those of other developers.
Git is more like a local database (it even allows multiple local checkouts against a single common “database”) and it only occasionally “deletes” old “garbage”. Anything you do locally in Git is atomic and can always be rolled back (provided garbage collection hasn’t yet been performed).
Although I’m comfortable enough with using the reflog to rollback changes (I’m also skilled enough in git I haven’t needed to in many years), it’s not very user friendly, it’s essentially like sifting through trash, you’ll eventually be able to find what you lost (provided it wasn’t lost too long ago), but you may have to dig around a bit. Hence my suggestion of tagging first, makes it easy to find it again if needed.
I have very limited Linux experience and have no recommendations on your other question.