0

I'm a total noob so thanks in advance for helping me. I've been trying to delete a push to GitHub and have been having some difficulties. I had one account set up on my Mac, no longer want to use it, and just when I thought I had it all set up with a different account, I did a test push and it pushed to the old account. I followed several different threads but seem to have encountered a problem with the menu to select a push to delete. The menu that I'm stuck at now looks like this:

pick (good push info)
pick (push I want deleted info)

Rebase (stuff)
Commands:
p, pic = use commit

r, reword = use commit, but edit the commit message

e, edit= use commit, but stop for amending
s, squash = use commit, but meld into previous commit
f, fixup = like "squash", but discard this commit's log message
x, exc = run command (the rest of the line) using shell

These lines can be re-ordered; they are executed from top to bottom
If you remove a line here THAT COMMIT WILL BE LOST.
However, if you remove everything, the rebase will be aborted.
Note that empty commits are commented out
-- INSERT--

At this menu, I can't get it to do anything. I don't know how to select what I need to in order to remove the push. I've tried hitting enter at different lines, and I'm stuck. Any help would be appreciated!!

  • 1
    possible duplicate of [How can I remove a commit on github?](http://stackoverflow.com/questions/448919/how-can-i-remove-a-commit-on-github) – Luceos Mar 03 '14 at 15:49
  • Those commands aren't working; the menu I'm stuck in is different. I already looked at that thread before I posted, but thanks for the suggestion! –  Mar 03 '14 at 16:02

1 Answers1

0

Hit 2gg then dd and then :wq<Enter>.

Agis
  • 32,639
  • 3
  • 73
  • 81
  • nothing happened? is there some specific place I'm supposed to type this in the menu? –  Mar 03 '14 at 15:55
  • While the `vi` editor opens up, press these keystrokes and you'll see that the 2nd line will be deleted, and then the file will be saved and the editor closed and the rebase will then continue. The commit should not be deleted. – Agis Mar 03 '14 at 16:15
  • It still doesn't seem to be doing anything. I typed 2gg dd :wq nothing happened. When I hit enter, it just skips to a new line. –  Mar 03 '14 at 16:22
  • Press `ESC` before starting to hit these keystrokes. You won't see anything typed into the screen, you will see that the line will be removed when you do the `dd` part. Just hit this keystrokes in the order I've telled you. `2+g+g`, `d+d`, `:+w+q` and . – Agis Mar 03 '14 at 16:24
  • OK so that did something! I'm sorry I'm a total noob. It says a bunch of new stuff in the terminal, but my GitHub account still shows the push. Do I need to follow this up with something else? –  Mar 03 '14 at 16:28
  • Yes you have to `$ git push -f` then, but be careful, this will rewrite history. If others have pulled from the remote repo they will face trouble. – Agis Mar 03 '14 at 16:29
  • the git push -f command seemed to do something, but when I check my github account, the push is still there but now it's been updated to about five minutes ago (while I've been doing all this). Any idea what I'm doing wrong? –  Mar 03 '14 at 16:37
  • If by "push" you mean "commit", then it means you have done something wrong. If you want to delete a commit you must: 1) do an interactive rebase in your local repo and delete the commit and 2) force push it to the remote repository. – Agis Mar 03 '14 at 16:45
  • However there is a better alternative, you can "revert" a commit. Simply do: `$ git revert ` and then just do a `$ git push`. – Agis Mar 03 '14 at 16:46
  • I think I did a push, meaning my github showed the file/code, and i typed $git push -f origin HEAD^:master and that worked! I saw someone had suggested that on another thread and it looked similar to what you suggested. Thanks for all your help!! –  Mar 03 '14 at 16:52