0

I want to change the very first commit message

$ git log --oneline
dfdbdf9 (HEAD -> master) databse changed and user post route created
aa29809 user model created
d8216e4 initial express server with route fies

How do I change the commit message with d8216e4 commit hast (very first).

I have tried

git rebase -i HEAD~3

but it shows something like this

fatal: Needed a single revision
invalid upstream 'HEAD~3'

Also , on using HEAD~1 or HEAD~2 , all git messages except the very first one are ediatbale

2 Answers2

0

Your repository has just three commits: HEAD, HEAD~1 and HEAD~2. There is no commit HEAD~3, hence the error.

You need to run git rebase -i --root.

abacabadabacaba
  • 2,662
  • 1
  • 13
  • 18
0

Use git rebase --root -i. From the manual:

   --root
       Rebase all commits reachable from <branch>, instead of limiting
       them with an <upstream>. This allows you to rebase the root
       commit(s) on a branch. When used with --onto, it will skip changes
       already contained in <newbase> (instead of <upstream>) whereas
       without --onto it will operate on every change. When used together
       with both --onto and --preserve-merges, all root commits will be
       rewritten to have <newbase> as parent instead.
A.H.
  • 63,967
  • 15
  • 92
  • 126