How do I reverse the latest uploads in git? [duplicate]

0

I accidentally sent the wrong files in Git, but I have not put them on the server yet.

How can I undo these Git appointments?

    
asked by anonymous 18.01.2018 / 02:24

1 answer

0
$ git commit -m "Enviado por engano"                        (1)
$ git reset HEAD~                                           (2)
<< edite os arquivos como for necessário >>                 (3)
$ git add ...                                               (4)
$ git commit -c ORIG_HEAD                                   (5) 
  • This is what you want to undo
  • This leaves your working tree (the state of your files in the disk) unchanged, but undoes the commit and leaves the changes that you have committed unregistered (then they will appear as "Changes not staged to confirm" in git status and you you need to add them again before confirming). If you want to only add more changes to the previous confirmation, or change the confirmation message1, you could use git reset --soft HEAD ~ instead, which is how git reset HEAD ~ (where HEAD ~ is the even HEAD ~ 1) but leaves your existing changes.
  • Make corrections to files in the file tree
  • git add anything you want to include in your new submission
  • Send the changes by reusing the old push message. reset copied the old header to .git / ORIG_HEAD; commit with -c ORIG_HEAD will open an editor, which initially contains the log message from the previous confirmation and allows you to edit it. If you do not need to edit the message, you can use the -C.
  • 1 Note, however, that you do not need to reset for an earlier submission if you just made a mistake in your confirmation message. The easiest option is git reset (to upload the changes you've made since then), and then git commit --amend , which will open your default commit message editor pre-populated with the last commit message. p>

    Be careful though, if you added new changes to the index, use commit - amend will add them to your previous commit.

        
    18.01.2018 / 02:36