简体   繁体   中英

How can I revert my local git repository to the state it has on GitHub?

I'm using Git and want to get rid of all my current changes and make my files look exactly like they do in my repo on GitHub. How do I do this?

I've been searching around and found things but I want to be careful not to mess anything up.

You can try this in a new directory first to make sure that you are certain of what it does. If you have a HEAD (possibly from a previous commit), you can use:

git reset --hard HEAD

This dumps your current changes and move back to where you last committed (ie where you last left off).

Hope it helps:)

See: http://git-scm.com/docs/git-reset

git reset --hard HEAD

This will help you get through.

If you want to start fresh with what is on github, the simplest route is to just make a new clone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM