在git中还没有推送到远程的几个提交 [英] Undo several commits in git which have not pushed to remote

查看:756
本文介绍了在git中还没有推送到远程的几个提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经运行git status和

I have run git status and

# On branch master
# Your branch is ahead of 'origin/master' by 4 commits.
#   (use "git push" to publish your local commits)
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   app/views/layouts/_header.html.erb
#
no changes added to commit (use "git add" and/or "git commit -a")

我想撤消在提交到远程存储库之前未提交的所有4个提交和更改。我怎样才能做到这一点?

I want undo all the 4 commits and changes not staged for commit before commiting to my remote repository. How can i do this?

推荐答案

这将丢弃工作树中的所有本地更改和四个最新的提交: p>

This will throw away all local changes in the working tree and the four latest commits:

git reset --hard HEAD~4

这篇关于在git中还没有推送到远程的几个提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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