![]() Below are three pretty common cases you've probably encountered yourself if you've been developing for a while. Sometimes this leads to errors being persisted in your Git history by accident, which then need to be corrected (no one wants to look like a fool in the eyes of fellow peers, right?). ![]() Whenever you get into a development flow, it's easy to unintentionally cut corners to keep the momentum going. 3 common reasons for undoing changes in Git In this post we'll look at three common reasons for wanting to undo changes in Git, and look at the specific commands reset, revert, and restore to decide what to use when. But considering Git's core concept of using immutable snapshots, undoing changes requires some thought-work and can feel daunting to begin with. I've said it before, and it's worth repeating: Git is undo on steroids! As a developer, wanting to undo changes already committed is commonplace during development. 6 min read Photo by Jose Antonio Gallego Vázquez / Unsplash.Just in case, if the logs show that the stash operation failed (by discarding uncommitted changes), it might still be possible to recover the changes.Logs under Help menu of GitHub Destkop App might provide more info on what happened behind the scenes.If the stash is available, then you could either pop or apply them depending on whether you want to remove the stash or preserve it for further use. If the uncommitted changes are not found using this, then you can switch to git CLI as suggested here and try listing the stashes ( make sure you are on the branch you want the uncommitted changes) by using the command git stash list. The issue of GitHub Desktop discarding the commits during the switching operation has been previously reported here for v2.2.2. Turns out that both options (highlighted above) internally perform stash operations for the respective branches. Stash your changes on the current branch, or bring the changes to your You can commit your changes on the current branch, You'll need to decide what to do with your changes before you can Quoting this from the GitHub Desktop help page, I'm not even sure which HEAD index to use to try to get my changes back how do I figure that out? Or is there another way to recover the changes? I went to the command line and entered "git reflog" and get the following: e328567 (HEAD -> master, origin/master, origin/HEAD, origin/branchNumberOne, branchNumberOne) checkout: moving from branchNumberOne to masterĮ328567 (HEAD -> master, origin/master, origin/HEAD, origin/branchNumberOne, branchNumberOne) checkout: moving from master to branchNumberOneĮ328567 (HEAD -> master, origin/master, origin/HEAD, origin/branchNumberOne, branchNumberOne) reset: moving to HEADĮ328567 (HEAD -> master, origin/master, origin/HEAD, origin/branchNumberOne, branchNumberOne) clone: from Now I can't find my changes in either branch. Before I had added them to staging, I listed the available branches and picked the one I wanted it asked me what I wanted to do with the current changes, and I chose an option that said I wanted to "bring them with me". When I had finished what I wanted to commit, I went to GitHub Desktop v2.2.3 and noticed that I was in master. I have hours of work that I did in that branch. I was working in the master branch and didn't realize it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |