0

Is there a way I can reset(using any mode) my changes after I add a commit, given there is only one commit in the history ?

Generally, if I need to reset, I would do,

git reset <mode> <commitId>

Now, since I have just one commit in my history, Is there any workaround to achieve this?

laxman
  • 1,781
  • 4
  • 14
  • 32
  • 1
    I came across the same issue a couple of years ago and since then I have been starting all my git repositories with a dummy commit, which contains a empty README file. Is it possible for you just to delete the `.git` directory and initialize a new git repo? – neshkeev Sep 01 '19 at 10:59

1 Answers1

3

Using Git commit amend should work:

git commit --amend -m 'first commit has changed'

This assumes that you have only made the initial commit, but you want to rewrite it. If instead you need to rewrite your branch history going all the back to (and including) the first commit, then read Edit the root commit in Git?.

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360