skip to content
Keshav Mohta

Recover last committed code from from a branch

/ 1 min read

How to Undo committed code in deleted branch

sometimes, we commit the code into a branch which is deleted remotely but available in local, and when we push the committed code, it throw error , so here is very easy steps to revert the changes from VS Code and preserve and commit in other branch.

  1. Go to VS Code SCM option ( from where you commit the code within VS Code)
  2. Go To ... and Commits > Undo Last Commit undo
  3. now your commit has been reverted and available under Changes Panel
  4. now stash these changes to commit in another branch
  5. to stash again click on ... > Stash > Stash (Included Untracked) stash
  6. it will ask to save as some name; keep any good name to remember
  7. now switch to another branch and apply the code using ... > Stash > Apply Stash and select your stash by the name you saved.

That’s all