返回到存储库中的特定修订后提交并推送更改? [英] Commit and push changes after going back to a particular revision in the repository?

查看:121
本文介绍了返回到存储库中的特定修订后提交并推送更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要回到特定的提交时间。掌握了一些意外的变化。试图恢复它挖得太深,所以主人处于不良状态。我们现在希望主人回到66ada4cc61d62afc。



根据 git回复到某些提交

  $ git reset --hard 66ada4cc61d62afc 
HEAD现在在66ada4c更新文档

然后,尝试提交它:

  $ git add * .h * .cpp 
$ git commit -m返回提交66ada4cc61d62afc
在分支大师
您的分支在后面'起源/主'由16个提交,并且可以被快速转发。
(使用git pull更新你的本地分支)

没有提交,工作目录干净

最后:

  $ git push 
到https:// github .com / weidai11 / cryptopp.git
! [被拒绝] master - >主(非快进)
错误:未能将一些文件推送到'https://github.com/weidai11/cryptopp.git'
提示:更新被拒绝,因为您当前的提示分支在
提示后面:它的远程对手。在再次推送之前,集成远程更改(例如
提示:'git pull ...')。
提示:有关详细信息,请参阅'git push --help'中的'关于快速转发的注意事项'。

现在,一切都正好在我想要的地方。我不知道Git为什么会遇到麻烦,Git在谈论什么。如果Git完成了它被告知的事情,那肯定会很好。但是,可惜的是,Git让每一项简单的任务都变得困难,并且它会给我们带来不必要的痛苦和痛苦。



我如何提交和推送更改?

解决方案

为避免部分解决方案简单地将一组错误交换为另一组错误,我执行了以下操作:

  git clone https://github.com/weidai11/cryptopp.git cryptopp-old 
git clone https://github.com/weidai11/cryptopp.git cryptopp -new

cd cryptopp-old
git checkout 66ada4cc61d62afc

cd ../cryptopp-new
cp ../cryptopp-old/*。 h ../cryptopp-old/*.cpp。

git commit -am返回提交66ada4cc61d62afc


We need to go back in time to a particular commit. Some accidental changes were made to master. Attempts to revert it dug too deep, so master is in a bad state. We now want master to go back to 66ada4cc61d62afc.

According to git revert back to certain commit:

$ git reset --hard 66ada4cc61d62afc
HEAD is now at 66ada4c Updated documentation

Then, trying to commit it:

$ git add *.h *.cpp
$ git commit -m "Go back to Commit 66ada4cc61d62afc"
On branch master
Your branch is behind 'origin/master' by 16 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

nothing to commit, working directory clean

And finally:

$ git push
To https://github.com/weidai11/cryptopp.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/weidai11/cryptopp.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Right now, everything is exactly where I want it to be. I have no idea why Git is having trouble, and what Git is talking about. It sure would be nice if Git did what it was told. But alas, Git makes every simple task difficult, and its going to inflict undue pain and suffering.

How do I commit and push the changes?

解决方案

To avoid partial solutions that simply exchanged one set of errors for another, I performed the following:

git clone https://github.com/weidai11/cryptopp.git cryptopp-old
git clone https://github.com/weidai11/cryptopp.git cryptopp-new

cd cryptopp-old
git checkout 66ada4cc61d62afc

cd ../cryptopp-new
cp ../cryptopp-old/*.h ../cryptopp-old/*.cpp .

git commit -am "Go back to Commit 66ada4cc61d62afc"

这篇关于返回到存储库中的特定修订后提交并推送更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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