0

I am trying to squash the git commits with following command

$ git rebase -i HEAD~3

But after running above command I am facing following error:

fatal: invalid upstream 'HEAD~3'

1

1 Answer 1

1

You get the invalid upstream <xxx> message when <xxx> doesn't match anything known to git.

In your case : if you are on a fresh branch with only 3 commits, HEAD~3 (the 3rd parent of current commit) does not exist, hence the message.


To squash commits together, you can use :

git reset --soft <sha of the first commit>  # or : git reset --soft HEAD~2
git commit --amend

If you want to use git rebase, there is a special --root option to say "rebase the whole branch" :

git rebase -i --root
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.