0

I am trying to do a rebase on the remote branch, but I get the following error:

$ git rebase -i origin/master~2 master
# fatal: invalid upstream 'origin/master~2'

I have tried to do a git fetch and git pull but it doesn't fix the problem.

In the git log I can see the following:

$ git log
# commit 611e384e89da3cec1e45bf59d7564580912e5073 (HEAD -> master, origin/master)
# Author: Shahrad Elahi <shahradq@gmail.com>                                     
# Date:   Sun Oct 30 14:38:57 2022 +0330                                         
#                                                                                
#     Initial Commit                                                             
#                                                                                
# commit 8ae591b238960b862eb67bbb37377b5ca1611c47                                
# Author: Shahrad Elahi <shahradq@gmail.com>                                     
# Date:   Sun Oct 30 14:34:50 2022 +0330                                         
#                                                                                
#     Initial Commit
Shahrad Elahi
  • 774
  • 12
  • 22

2 Answers2

2

If you only have 2 commits, you cannot rebase onto the third-last. origin/master is 611e38; origin/master~1 is 8ae591; origin/master~2 does not exist. If you want to rebase all commits, including the root commit, use git rebase -i --root.

knittl
  • 246,190
  • 53
  • 318
  • 364
1

That's not gonna fly because origin/master~2 does not exist. Try git rebase -i --root master

eftshift0
  • 26,375
  • 3
  • 36
  • 60