I want to squash the last two commits with the commit messages “first” and “second”. First I pull out the master, then I use the command
git rebase -i HEAD~2 master
It shows that both commits in the editor are as follows:
pick first pick second
Then I change this editor as follows:
pick first squash second
After saving the changes, I received this message:
Successfully rebased and updated refs/heads/master.
This has not changed anything remotely. To apply these changes, I use the git push command and received the following error:
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 (eg 'git pull') hint: before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Then I run the git pull command again and it combines the original master and makes another commit with this commit message:
Merge branch 'master' of https:
After that, when I run git push, it goes through two commits into one with the message “first”. The problem is that the remote master now has four commits:
first second Merge branch 'master' of https://github.com/test/GITtest first
Where I want only one commit, which is crushed with the message "first". Any ideas where I'm wrong?
github
user2460869
source share