Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

cancel a commit not pushed

git reset --soft HEAD~
Comment

git how to undo a pushed commit

git revert <commit_hash>
Comment

git remove last pushed commit

git reset --hard 'xxxxx'

git clean -f -d

git push -f
Comment

git undo pushed commit

git reset <previous label or sha1>
git commit -am "commit message"
git push -f <remote-name> <branch-name>  //  git push -f origin master
Comment

delete last pushed commit

$ git reset <previous label or sha1>
$ git commit -am "blabla"                    <--- optional
$ git push -f <remote-name> <branch-name>    
Comment

undo last commit pushed

git reset # commitId
# Exemple
git reset 5310517
Comment

github undo last pushed commit

git reset <previous label or sha1>
git commit -am "blabla"
git push -f <remote-name> <branch-name>
Comment

how to revert last pushed commit

To reset a brancj to some good commit:

In the server, move the cursor back to the last known good commit:

git push -f origin <last_known_good_commit>:<branch_name>

Locally, do the same:

git reset --hard <last_known_good_commit>
#         ^^^^^^
#         optional
Comment

how to revert last pushed commit

git reset <previous label or sha1>
git push -f <remote-name> <branch-name>  //  git push -f origin <branch-name>
Comment

how to undo last pushed commit

git revert <commit_hash>
Comment

undo pushed commit

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 :: push local branch changes to remote branch 
Shell :: ubuntu command upgrade application 
Shell :: add folder to github 
Shell :: git clone set directory 
Shell :: clone code -lr 
Shell :: compress folder pigz 
Shell :: aws ssh warning unprotected private key file 
Shell :: batch file path 
Shell :: ssh passphrase stop asking 
Shell :: read lines bash script 
Shell :: ubuntu disable auto suspend command line 
Shell :: check bluetooth radio status bash 
Shell :: squash commits git 
Shell :: curl insecure 
Shell :: sed tab to space 
Shell :: docker compose up 
Shell :: git patch staged to file 
Shell :: redux installation 
Shell :: gatsby typescript template 
Shell :: how to create an alias 
Shell :: how to remove bin folder from git 
Shell :: gatsby plugin image 
Shell :: arch linux install guide 
Shell :: ps command 
Shell :: git delete all remote branch except master 
Shell :: how to install cab file in ubuntu 
Shell :: what is the option to sort by file size in unix 
Shell :: create windows 10 bootable usb in ubuntu 
Shell :: git diff between branches file 
Shell :: how to pull from specific branch 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =