Git rebase 首先 2 Commit

标签 git

这是我到目前为止所做的。我要做的是在推送之前将第一次和第二次提交 merge 为一个提交(尚未添加远程存储库)。

$ git init

$ vim myprogram

$ git add myprogram && git commit -m "Initial commit"

$ vim README.md

$ git add README.md && git commit -m "Added readme"

$git log --pretty=oneline
b8e2979 Added readme
a579d65 Initial commit

$ git rebase -i HEAD~2
fatal: Needed a single revision
invalid upstream HEAD~2

我做错了什么导致了 fatal error 。

如果有人问过这个确切的问题,请标记它并提供链接。

最佳答案

您想使用 --root选项:

... Rebase all commits reachable from <branch>, instead of limiting them with an <upstream>. This allows you to rebase the root commit(s) on a branch. ...

git rebase -i --root

关于Git rebase 首先 2 Commit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39071409/

相关文章:

git - 如何为 Gitlab 运行器启用通过 SSH 的克隆?

git - Git Stash 后一些文件消失了

ruby - Gemfile.lock 应该包含在 .gitignore 中吗?

javascript - 有没有办法用 JavaScript 读取 Git 标签

svn - 为什么在 Mercurial 中分支和 merge 比在 Subversion 中更容易?

git - 如何在git中找到最后 checkout 的分支

json - 公共(public)服务器上的 Git、Node.js 和 NPM

git - 如何将另一个开发人员的分支 merge 到我的分支中?

git - 为什么要选择 ATX 或 SETEXT Markdown 标题样式?

git - 如何在 IntelliJ IDEA 2016.1 中使用 git worktrees?