Search code examples
gitpullgit-checkoutrevert

How to get back modified file after git checkout and git pull?


I've modified a file, then I want to get latest version from remote.

So I run git checkout to revert the file, and run git pull to get latest version.

After that, I found that I need the modification of the file.

Is it possible to get it back? Thanks!


Solution

  • Use "git stash" to stash all of your changes, "git pull" to update your repository, and then "git stash apply" to apply your changes back.