- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我用过
git reset --hard dc082bc...由于一些错误的提交,将分支恢复到所需的先前状态。这已经恢复了我本地的分支机构。但是,我想将“origin”上的分支倒回同一个提交,以便我可以重新开始。谁能告诉我如何将原始分支(不是主分支)恢复到此提交?
我试过 git push origin master,但它给出了以下错误
! [rejected] branch -> branch (non-fast-forward)error: failed to push some refs to 'git@github.com:xxx/xxx.git'To prevent you from losing history, non-fast-forward updates were rejectedMerge the remote changes before pushing again. See the 'Note aboutfast-forwards' section of 'git push --help' for details.
最佳答案
添加到我的previous answer ,并且为了解决强制 git push
确实会弄乱其他贡献者的本地存储库这一事实,git 1.8.5(即将于 2013 年第四季度发布)将看到一个新选项:
git push --force-with-lease
在 this thread 中查看该选项的来源:
if something happens at '
origin
' to the branch you are forcing or deleting since you fetched to inspect it, you may end up losing other people's work.Somebody who is unaware of the decision to rewind and rebuild the branch may attempt to push to the branch between the time you fetched to rebase it and the time you pushed to replace it with the result of the rebasing.
We can
make these pushes safer
by optionally allowing the user to tell "git push
" this:I am forcing/deleting, based on the assumption that the value of 'branch' is still at this object.
If that assumption no longer holds, i.e. if something happened to the branch since I started preparing for this push, please do not proceed and fail this push.
您可以在commit 28f5d17 中查看--force-with-lease
的完整文档
--force-with-lease
will protect all remote refs that are going to be updated by requiring their current value to be the same as some reasonable default, unless otherwise specified;For now, "some reasonable default" is tentatively defined as "the value of the remote-tracking branch we have for the ref of the remote being updated", and it is an error if we do not have such a remote-tracking branch.
解释该选项的“租赁”部分:
"
force-with-lease
": You assume you took the lease on the ref when you fetched to decide what the rebased history should be, and you can push back only if the lease has not been broken.
这已经在测试中,并在“What's cooking in git.git (Aug 2013, #07; Wed, 28)”中提到:
By the way, the push that overrides the usual "must fast-forward" was done using the "
force-with-lease
" option that has been cooking innext
, like so:
$ git fetch ko next
$ anchor=$(git rev-parse --verify FETCH_HEAD)
$ for remote in ko repo gph github2
do
git push --force-with-lease=refs/heads/next:$anchor $remote next
done
注意:“git push --force-with-lease
”已经被教导报告如果推送需要强制(或快进)。
所以这个命令在 git 2.8(2016 年 3 月)的输出中更加详细
push: fix ref status reporting for
--force-with-lease
The
--force--with-lease
push option leads to less detailed status information than--force
.
In particular, the output indicates that a reference was fast-forwarded, even when it was force-updated.
当心该选项被忽略/绕过,如explained in Git 2.13 (Q2 2017) .
关于Git:如何忽略快进并将原点[分支]恢复到较早的提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3166713/
我正在使用 just_audio而且效果很好。 但似乎找不到快进或倒带的方法。 更新:原来 just_audio 是 audio_service 的一部分包,使用 audio_service 为我解决
我让它快进了,但我想在快进时听到音乐。我怎样才能做到这一点?这是我的代码: if node.name == "left" { var time = musicPlayer.cu
可以假设快进意味着所有提交都在目标分支上重播并且 HEAD 设置为该分支上的最后一次提交吗? 最佳答案 当您尝试将一个提交与一个可以通过跟踪第一个提交的历史记录到达的提交 merge 时,Git 会通
关闭。这个问题需要更多 focused .它目前不接受答案。 想改进这个问题?更新问题,使其仅关注一个问题 editing this post . 8年前关闭。 Improve this questi
我有一个音频播放器,可以播放从 Core Date 检索到的音频。播放和暂停工作正常。我正在尝试实现“向前跳转 30 秒”按钮,并寻求有关我将如何实现的任何指示。 “播放/暂停”按钮的代码 @IBAc
Git merge 允许我们执行快进和非快进分支 merge 。什么时候使用快进 merge 以及什么时候不使用快进 merge 有什么想法吗? 最佳答案 --no-ff 选项在您想要清楚地了解您的功
我有这种情况:在一些 testBranch 上工作了一段时间,我想与 master 同步所以我做了git checkout testBranch 和git merge master/testBranc
所以我正在做一个项目,我有很长的 for 循环,当接近循环结束时我通常会遇到问题,但是通过进入循环数百万次手动到达那里几乎是不可能的。我知道我可以只更改计数器变量,但在这种情况下它不起作用,因为每次迭
我正在我的 Mp3 播放器中制作快进按钮。我已经为此编写了代码,但是有问题如何实现计时器向前跳 5%?我的意思是,当我按下按钮时,计时器应该比总长歌曲向前跳 5%。这是我的 fastForward 方
MediaPlayer 的 pause() 方法使 Media 稍微“寻找”一下。确实很烦人,但是没找到问题出在哪里。 private void playPauseClicked()
我有一个包含两个分支 master 和 entidades 的 GIT 存储库。我需要将 entidades 分支中的一些内容 merge 到 master 分支。看一下图像,标记为 EntityBu
假设有一个功能分支'my-feature'。在我开发该功能时,有人将它从“我的功能” merge 到“主控”中。因为这是一个快进 merge ,所以没有提交。我所做的一些更改还没有准备好用于 mast
换句话说,快进 merge 是否能保证生成与要 merge 的源分支的 HEAD 相同的 GIT SHA? 我在终端中测试了此行为,它适用于我的测试场景: $ git rev-parse some-b
换句话说,快进 merge 是否能保证生成与要 merge 的源分支的 HEAD 相同的 GIT SHA? 我在终端中测试了此行为,它适用于我的测试场景: $ git rev-parse some-b
这个关于 git 的陈述是真的吗,merge(其中快进是可能的)基本上与使 git reset --hard 到 HEAD 相同要 merge 到的分支? (当merge不是fast-forward时
最近,我创建了newbranch,并创建了一个到Master分支的 merge 请求。在 TeamLead 接受 merge 请求到 Master 分支之前,另一个团队成员向同一个分支(新分支)提交了
我是一名优秀的程序员,十分优秀!