如何在Git中放弃本地提交? [英] How to discard local commits in Git?

查看:126
本文介绍了如何在Git中放弃本地提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在做一些事情,并决定完全搞砸了......在做了一些事情之后。所以我尝试了以下顺序:

  git reset --hard 
git rebase origin
git fetch
git pull
git checkout

何时我收到消息

 您的分支在2次提交之前超过'origin / master'。 

我想放弃我的本地提交,而不必消灭我的本地目录并重新下载所有内容。

解决方案

  git reset --hard origin / master 

将删除所有不在 origin / master 中的提交,其中 origin 是仓库名称, master 是分支的名称。


I'd been working on something, and decided it was completely screwed...after having committed some of it. So I tried the following sequence:

git reset --hard
git rebase origin
git fetch
git pull
git checkout

At which point I got the message

Your branch is ahead of 'origin/master' by 2 commits.

I want to discard my local commits, without having to wipe out my local directory and redownload everything. How can I accomplish that?

解决方案

git reset --hard origin/master

will remove all commits not in origin/master where origin is the repo name and master is the name of the branch.

这篇关于如何在Git中放弃本地提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆