2

I pushed a commit with date in the future:

enter image description here

I want to delete it but:

  • I only found ways to do it with my local repo
  • I made that commit in a machine that is currently unavailable
  • That commit doesn't appear in my current machine even if I pull

Is there a way to delete it using github's web interface?

Is there a way to "force pull" that commit to delete it locally and then push the deletion?


Update

I found the commit but it had a different time than the one shown in github enter image description here

I tried modifying the commit using git rebase <id> -i but the commit doesn't appear in the rebase

enter image description here

The commit that I'm trying to change is the one that starts with 03.

tripleee
  • 175,061
  • 34
  • 275
  • 318
Alechan
  • 817
  • 1
  • 10
  • 24
  • 3
    You don't need to get it locally to delete it. Just make sure your local branch's latest commit is the one from Nov. 8, and force push your local branch. – JB Nizet Nov 08 '18 at 22:18
  • Very nice, how did you commit on Dec 2201? – Karol Dowbecki Nov 08 '18 at 22:19
  • I guess setting the time of the computer to be in the future is a way. And I think there are environment variables to set whatever values we want for author and committer dates. – eftshift0 Nov 08 '18 at 22:24
  • @JBNizet, I found the commit but I can't modify it. I updated the question. Karol Dowbecki, eftshift0, I have no idea why it happened. – Alechan Nov 08 '18 at 22:44

1 Answers1

1

Regarding a rebase, make sure to start it with the commit before the one you want to change, or it won't be part of your rebase task list.

But I would use a git filter-branch as this one, in order to hcange the author date of a commit.

git filter-branch --env-filter \
    'if [ $GIT_COMMIT = 03...]
     then
         export GIT_AUTHOR_DATE="Fri Jan 2 21:38:53 2009 -0800"
         export GIT_COMMITTER_DATE="Sat May 19 01:01:01 2007 -0700"
     fi' SHA1..HEAD

Again: make sure SHA1 is the one before the 03... you want to change.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250