You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently had a slip-up where I meant to unstage some changes, but did git fire instead of git demote, leading to accidentally deleting the changes.
I was able to recover, but it brought up a problem. Git is relatively unsafe with removing local changes, and there's not really a built-in way to make this safer.
I think I have a good solution: create a little script that archives the uncommited changes before removing them. Here's what I have so far:
(I'm using long-form for command line options, since this will be in a script and succintness matters less than clarity)
This does most of what I want, but it's missing some finer detail. It doesn't function at all if there are no uncommited changes, and it's just putting the archive in the current directory. We also should consider how many archives to save. However, I'll leave this conceptual question for future me.
Once done, we can just make our git alias for deleting changes make an archive before it runs, via ! syntax. This will ensure that if we fuck up, we can quickly just check the archive.
The text was updated successfully, but these errors were encountered:
I recently had a slip-up where I meant to unstage some changes, but did
git fire
instead ofgit demote
, leading to accidentally deleting the changes.I was able to recover, but it brought up a problem. Git is relatively unsafe with removing local changes, and there's not really a built-in way to make this safer.
I think I have a good solution: create a little script that archives the uncommited changes before removing them. Here's what I have so far:
(I'm using long-form for command line options, since this will be in a script and succintness matters less than clarity)
This does most of what I want, but it's missing some finer detail. It doesn't function at all if there are no uncommited changes, and it's just putting the archive in the current directory. We also should consider how many archives to save. However, I'll leave this conceptual question for future me.
Once done, we can just make our git alias for deleting changes make an archive before it runs, via
!
syntax. This will ensure that if we fuck up, we can quickly just check the archive.The text was updated successfully, but these errors were encountered: