2

I have a project to which I commit almost daily and I would like to delete a commit from around 4 days ago, so that it would appear that the commit after that one was made immediately after the commit before it. The problem is a silly comment that is not very professional and that I wouldn't like to be seen (but now it can be seen very clearly with the diff feature of Sourceforge).

Ioana
  • 343
  • 5
  • 10
  • 1
    See http://stackoverflow.com/questions/1338728/how-to-delete-a-git-commit?rq=1 also the not accepted answers – johannes Jul 01 '13 at 23:41
  • Also see http://stackoverflow.com/questions/457379/how-do-i-edit-an-incorrect-commit-message-in-git-ive-pushed – Magikhead Jul 03 '13 at 19:57

1 Answers1

2

If the change has already been pushed (i.e. not in your local branch) then you might want to just forget about it. Because git is a distributed software configuration management tool, others may have pulled your changes and could potentially revert anything you try and undo. From the linked question above it is explained rather well:

However, if others may have pulled it, then you would be better off starting a new branch. Because when they pull, it will just merge it into their work, and you will get it pushed back up again.

If you already pushed, it may be better to use git revert, to create a "mirror image" commit that will undo the changes. However, both commits will both be in the log.

In general, making deletions on origin/master kind of goes against the whole idea of source control. You should be tracking all code, the good & bad.

Community
  • 1
  • 1
Magikhead
  • 124
  • 1
  • 6