How does Git discard local changes and update the latest version of the remote repository locally?

I modified the code on the first computer yesterday, but I didn"t submit it to github. Then after going back, git clone url downloaded the code on the second computer, modified it, and then submitted it to github. I now want to update the local warehouse on the first computer to the latest version of github. I didn"t want to change the code that was not submitted yesterday. What should I do, please? After using git fetch origin master, I saw that the code in the local repository is not the latest code on github.

Mar.04,2021

There are many

methods, and here is a relatively simple and easy to understand method:



git reset --hard <commit-id>   // 

git pull                       // 


git checkout. Abandon the current operation
git pull origin branch to pull the latest


  1. it is recommended to install a graphics client. Under Windows, you can use tortoise TortoiseGit,Mac. You can use GitHub or SourceTree, to right-click revert.
  2. if it is not submitted, then the git checkout master file name is checked out to the normal version directly.

this long fried egg, you make a copy of those packages and then delete the items, re-copy them to become the latest ones, and then bake the copied node_modules things in, and then you can do what you want to do again. For the above method, if you are not clear about the specific function, do not use ~


git stash


execute first:
git reset-- hard commit version number / / commit version number is the last submission record pulled before you modify the local code
and then execute:
git pull

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3501f-2b6d8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3501f-2b6d8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?