git rebase fatal: 必要なリビジョンが 1 つだけあります。上流に無効なリビジョンです –i 質問する

git rebase fatal: 必要なリビジョンが 1 つだけあります。上流に無効なリビジョンです –i 質問する

複数のコミットをまとめて圧縮しようとしています。

git rebase –i HEAD~8

致命的なエラーが発生しています:

fatal: Needed a single revision
invalid upstream –i

以下はコミットログの一部です:git ログ

対応する Github リポジトリのすべてのコミット履歴はここにあります:https://github.com/yikouniao/YukiLog/commits/master

編集1:

git を使用した場合rebase –i HEAD~2、同じ結果が得られました。

編集2:

ファイル を変更したことに気づかず.gitconfigeditor = notepad2がファイルに追加されました。 を削除した後editor = notepad2、すべて正常になりました。その後、8 つのコミットをリベースして圧縮することに成功しました。

ベストアンサー1

いくつかのオプション:

  • Detached headブランチ ( )上にいないか、rebase間違ったブランチをチェックアウトしようとしている可能性があります。
    目的のブランチをチェックアウトしてrebase、もう一度試してください。

  • 履歴に 8 つのコミットがありません (7 つ以下です)

  • 試す:git rebase -i --root

フラグに関するドキュメント--rootと、それが機能する理由を以下に示します。

--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.  
When used with --onto, it will skip changes already contained in `<newbase>`   
(instead of `<upstream>`) whereas without --onto it will operate on every 
change. When used together with both --onto and --preserve-merges, all root 
commits will be rewritten to have `<newbase>` as parent instead.`

おすすめ記事