![]() ![]() Next time they push, they'll try and re-instate them as the local clones "see" that the origin does not have the objects (commits) that you have deleted. The interactive rebase deletes the commits to the extent that there is no record of them, so the other clones do not know they have been deleted. It's important to note that if you have already pushed your code and others have pulled it, the above will not work as the commits will find their way back in there the next time someone who has your branch checked out does a push. So, delete the lines that reference the commits you want to be rid of, save and close, and git will handle the rest (you may have to fix some conflicts depending on the nature of the commit and the revert you're trying to delete). The key bit for you is If you remove a line here THAT COMMIT WILL BE LOST. ![]() # Note that empty commits are commented out # However, if you remove everything, the rebase will be aborted. You need to pass the -f because youre replacing upstream history in the remote. (Example push: git push -f origin bugfix/bug123) This will undo the last commit and push the updated history to the remote. # If you remove a line here THAT COMMIT WILL BE LOST. git reset -hard HEAD1 git push -f .# These lines can be re-ordered they are executed from top to bottom. # x, exec = run command (the rest of the line) using shell # f, fixup = like "squash", but discard this commit's log message ![]() # s, squash = use commit, but meld into previous commit The solution however can be found by looking at what was recorded by running git reflog and then manually running the git reset to before VS. These actions are in the output if you open up the 'GIT' tab. VS Code 'Undo Last Commit' simply runs git reset HEAD. # e, edit = use commit, but stop for amending The answer is really quite simple after looking into what 'undo' actually does. # r, reword = use commit, but edit the commit message When you get editor up as a result of issuing the above, take a look at the comment in the opened file: # Commands: Click Commit to commit a changeset that reverts changes to the selected files in this particular commit. If the selected commit contains several files, and you only need to revert some of them, deselect the files you do not want to touch. where -i is the interactive flag, and HEAD~5 means include the last 5 commits in the interactive rebase. The Commit Changes dialog will open with an automatically generated commit message. Iâll walk you through some use cases of the reset command and different ways you can implement it, along with a few examples. It can be a tad bit tricky to grasp, so Iâll demystify some underlying concepts for you in this post. I hadn't thought of that.As others have said: $ git rebase -i HEAD~5 You can use Git to travel back in time and safely undo your changes in a project through a command called git reset. :)Ä®dit: As Edward Thomson commented above, you may be able to recover using git-recover if you first staged your changes. If you agree, please accept as Answer even if you don't get your file back. This still is an answer to your question even if you cannot successfully Undo your Undo operation and get your file restored. You should not be able to accidentally click it and suffer consequences unless you confirm that it's really what you want to do. The link you cite does not mention anything of the sort with respect to using Undo.Ä«y the way, Undo presents an "Are you sure?" dialog box. It does not do anything with local branches and it does not push. Undo only reverts changes to the file you select in Solution Explorer. Finally, you might be able to use a data-recovery product such as R/Studio to recover your file, although this probably won't work if you've replace a file with old contents by using Undo. Other than that, if you might have made a backup copy or if your machine is part of a scheduled backup, you might find your file archived somewhere. You can try to go to your Visual Studio folder and check the Backup Files folder for the old version of your file. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |