コミット メッセージが「first」と「second」の 2 つの最新のコミットをスカッシュしたいと考えています。最初にマスターをプルしてから、コマンドを使用します
git rebase -i HEAD~2 master
次のようなエディターで両方のコミットが表示されます。
pick first
pick second
次に、このエディターを次のように変更します。
pick first
squash second
変更を保存した後、次のメッセージが表示されました。
Successfully rebased and updated refs/heads/master.
リモートマスターの何かを変更しました。これらの変更を適用するために、git push
コマンドを使用すると、次のエラーが発生しました。
To https://github.com/aneelatest/GITtest.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/test/GITtest.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
次に、git pull
コマンドを再度実行すると、元のマスターがマージされ、次のコミット メッセージで別のコミットが行われます。
Merge branch 'master' of https://github.com/aneelatest/GITtest
この後、git push を実行すると、2 つのコミットが「first」というメッセージで 1 つにまとめられます。問題は、リモート マスターに 4 つのコミットがあることです。
first
second
Merge branch 'master' of https://github.com/test/GITtest
first
コミットメッセージ「最初」で押しつぶされたものであるコミットが1つだけ必要な場合。私が間違っているアイデアはありますか??