3 ms·
One thing I wish git did differently was to have an atomic commit-and-push operation. I'd like to prepare my commit as normal, but when its ready, it pushes tha
by billpg 4y ago
One thing I wish git did differently was to have an atomic commit-and-push operation. I'd like to prepare my commit as normal, but when its ready, it pushes that commit as well, but if that push fails, it undoes the commit.
Why? I recently configured my github to use a hidden email address. To this end, it required me to use a github.com email address it generated for my commits. I set it up and started pushing commits, everyone was happy.
Then I went to a different folder that had a separate clone of the same repo, and I forgot I had configured github this way. I made some changes and did the usual commit-and-push but github rejected it. I had used the wrong email. Oops.
But now I had a problem. My local repo had the commit with the wrong email address in place and I didn't know to change it. I couldn't make a new commit with the new email as the old one was still there. I looked up how to revert already committed commits and long story short I did it wrong and deleted all my recent changes.
- Sverigevader 4y agoSorry this happened to you. Next time, if you want to reset the latest commit to an unstaged state: git reset HEAD~ But regarding "deleting all my recent changes", another command I'd like to introduce you to is; git reflog It shows you all of your commits that changed the tip (HEAD). Chances are your changes could be found there. I don't blame you for not knowing this. I learned by trial and error and most importantly, good colleagues who showed me the way. edit: Typo/grammar