2

I'm trying to squash my last 2 commits with git. In this example I have created a branch from another branch called develop and I have 3 new commits, this is the git log :

commit a350cf6071db1bcaa2a37710a61508565a34d917
Author: tibbus
Date:   Tue Sep 6 11:49:19 2016 +0200

    commit message #3

commit 8c0384b995831e5a62b423721434005788b2eb63
Author: tibbus
Date:   Tue Sep 6 11:49:01 2016 +0200

    commit message #2

commit 6eab9df2df71196d62dab3c6caed9cd0ac6aeee5
Author: tibbus
Date:   Tue Sep 6 11:48:41 2016 +0200

    commit message #1
...
more commits from develop...

So I want to squash commit #3 and commit #2 into one single commit, I try :

git rebase -i HEAD˜2

and I get this error :

fatal: Needed a single revision
invalid upstream HEAD˜2

If I do :

git rebase -i develop

Works fine, but I do not want to squash all 3 commits, I want only the latest 2. I have read that this error appears when you don't have enough commits, but I definitely have ¯_(ツ)_/¯

Tiberiu Popescu
  • 4,486
  • 2
  • 26
  • 38
  • Will you please post the output of "`git log --oneline --graph --decorate`"? – Leon Sep 06 '16 at 10:14
  • Hi @Leon , thanks for for your interest. I have saved that command log into a jsfiddle to be more easy to read : https://jsfiddle.net/083kvr6b/2/ – Tiberiu Popescu Sep 06 '16 at 10:34

2 Answers2

1

You are using a wrong ~ symbol. ˜ in your command is the small tilde non-ASCII character, whereas you need the regular tilde ASCII symbol. Did you copy it from somewhere or the ~ on your keyboard inserts ˜?

Copy&paste the command from my answer and it should work without any problem:

git rebase -i HEAD~2
Leon
  • 31,443
  • 4
  • 72
  • 97
1

Check your tilda (~). Seems to be a different ASCII and hence git command line is asking for a revision.

SLearner
  • 1,419
  • 5
  • 18
  • 22