Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

git how to undo a pushed commit

git revert <commit_hash>
Comment

how to undo a bunch of commit sent that was pushed

git revert <oldest_commit_hash>..<latest_commit_hash>
Comment

how to undo a commit sent that was pushed and keep local changes

git reset <previous label or sha1>
Comment

how to undo an already pushed commit

Note: the steps below does not remove the previous commit.
It simply reverts it to what it was.

Step one is to ensure that you are on a clean working directory.
You shouldn't have any open new changes.

Then you'll need to find the hash for the specific commit you are trying to undo.
You can find them on your online Repo (like GitHub, for instance).

Take this hash and then head back over to your terminal.
You can now revert this commit by executing the following command.

for example if the hash is f193a70


$ git revert f193a70 --no-edit


Note: The --no-edit is optional. It won't prompt you to edit
the commit message that way

Once executed, you'll note that it will do the opposite of the commit locally.

The command will return the files to what they used to be before.

Now all that's left is to push the reverted code.


$ git push


When you view your changes, you'll see the old commit is still there,
but a new revert commit replaces the changes.
Comment

PREVIOUS NEXT
Code Example
Shell :: configure a subdomain apache windows 
Shell :: how to save changes made to models in django 
Shell :: basename bash 
Shell :: shutdown shortcut ubuntu 
Shell :: jinja escape 
Shell :: install deno 
Shell :: chmod user to root 
Shell :: install nodejs via homebrew 
Shell :: scp from server to my computer 
Shell :: present working directory in linux 
Shell :: git recurse submodules 
Shell :: Add a Remote Repository in git command 
Shell :: comment installer tar.gz 
Shell :: rebase github 
Shell :: selenium run chhrome headless 
Shell :: Why github ask me username/password instead of SSH authentication? 
Shell :: undo pushed commit 
Shell :: powershell make directory 
Shell :: how to push repository to github 
Shell :: how to execute script and pass a parameterin linux 
Shell :: linux ssh into machine with private key 
Shell :: close vim 
Shell :: phoenix liveview setup 
Shell :: create biitable usb installer for macos 
Shell :: how add ssh 
Shell :: git remove an empty commit 
Shell :: composer download 
Shell :: install ktorrent pacman 
Shell :: .bash_profile mac mvn 
Shell :: popular git command 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =