Search code examples
gitgit-pullgit-stash

git pull replaces existing code


After I committed files in Git, I made a pull request but it stops some of my code functionality. I want to go to the previous stage, before I committed my files, the state previous to this pull request.

I found git stash is an option to go to previous stage. But there are many options given with it like

git --rebase
git stash
git stash pop

Other commands I've tried include:

git status
git commit file1 file2 file3 -m "message"
git commit -i file1 file2 file3 "message"
git pull
git checkout 

Which commands do I need to use to go to the stage before pull?


Solution

  • You have to use git stash beforehand. If you didn't, you can try to guess your previous state by running git log -g.

    Among the results find commits with "message". One of them is what you're looking for.