简体   繁体   English

如何将我的本地 git 存储库恢复到它在 GitHub 上的 state?

[英]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.我正在使用 Git 并希望摆脱我当前的所有更改并使我的文件看起来与我在 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:如果你有一个 HEAD(可能来自以前的提交),你可以使用:

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见: 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.如果您想从 github 上的内容重新开始,最简单的方法是制作一个新的克隆。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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