0

I am trying to learn how to modify a specified commit (fe4e3fc) that is not HEAD by following @ZelluX answer . However, I encountered the following error

$ git log --oneline
b18762f Added Hey Hey
aa9c57d Put Hey in test
fe4e3fc Initial Test
$ git rebase --interactive fe4e3fc^
fatal: Needed a single revision
invalid upstream fe4e3fc^
$

I noticed that he had the ^ after the hash in his answer. Any assistance helping me understand how to edit a commit that is not HEAD will be appreciated. Thanks in advance.

Community
  • 1
  • 1
Anthony
  • 3,990
  • 23
  • 68
  • 94
  • 1
    What answer are you referring to? I don't see a link to another SO question. – Chris Hayes Sep 01 '13 at 22:26
  • The link is after @ZelluX. I'll make the link wider now – Anthony Sep 01 '13 at 22:27
  • 1
    I see now - I've visited it before so it didn't stand out at all. My mistake. – Chris Hayes Sep 01 '13 at 22:27
  • +1 No, my bad, I should have made the link much wider to begin with. Thanks for pointing that out. – Anthony Sep 01 '13 at 22:28
  • 2
    Potentially handy: http://stackoverflow.com/questions/2246208/change-first-commit-of-project-with-git & http://stackoverflow.com/questions/2119480/edit-amend-modify-change-the-first-root-initial-commit-in-git – Chris Sep 01 '13 at 22:30

1 Answers1

1

The ^ character means "find the first parent of the commit with this ref/hash". Therefore, fe4e3fc^ means "find the parent of the commit with hash fe4e3fc". Since that is the initial commit for the repo, this is naturally impossible, because there are no commits prior to that one.

Also worth knowing about is the ~ character, which is similarly used to specify the parent (or grandparent, etc.) of a commit. See this question for some detail on how ^ and ~ work. In this case, you could use HEAD~2 and be referring to the same commit, fe4e3fc, because it is two "generations" back from HEAD.

If your goal is to modify the initial commit in some way, see this question.

Community
  • 1
  • 1
Chris Hayes
  • 11,471
  • 4
  • 32
  • 47