0

I created a branch from Master using git checkout -b mybranch. After modifying some files I wanted to commit but couldn't because of some error. After reading some posts I deleted the git index (rm .git/index) and was able to commit afterwards. However, now I see that the files I did not modify are missing and are not in the index anymore, whereas the files I modified are there. I can't Add the missing files to the index; the Add option is greyed out (in IntelliJ). But I also want to do more than just add the missing files: I want to fix that original commit. How can I do that?

Update: I don't know enough Git to know that this is the same a moving "Head" back; hence the question. I think it will be useful to complete Git newbies like myself. Thank you for pointing out that this is effectively what I need to do.

Kai
  • 1,464
  • 4
  • 18
  • 31
  • is it possible for you to provide git reflog output? – danglingpointer Apr 07 '17 at 14:51
  • I made a mistake of doing the first commit in IntelliJ, so the terminal command history is incomplete. What I can see is git checkout followed by rm .git/index followed by a git commit -m "xxxxx". Are there any commands I can run and post the output of here? – Kai Apr 07 '17 at 15:02
  • Did you try git reset ? – fightingCoder Apr 07 '17 at 16:31
  • I did a git add . then committed. That worked, maybe not the textbook way, by it does not "fix" the original sin (commit), but it works. – Kai Apr 07 '17 at 16:42

0 Answers0