Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

git remove last pushed commit

git reset --hard 'xxxxx'

git clean -f -d

git push -f
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 git commit after push

git reset <hash> # Run this then merge, commit, and push
Comment

how to undo commits after push

You can revert individual commits with:

git revert <commit_hash>
This will create a new commit which reverts the changes of the commit you specified. Note that it only reverts that specific commit, and not commits that come after that. If you want to revert a range of commits, you can do it like this:

git revert <oldest_commit_hash>..<latest_commit_hash>
It reverts all the commits after <oldest_commit_hash> up to and including <latest_commit_hash>. On some versions of git it also reverts the <oldest_commit_hash>, so double check if that commit gets reverted or not. You can always drop the latest revert commit (which reverts the oldest commit) with g reset --hard HEAD~.

To know the hash of the commit(s) you can use git log.

Look at the git-revert man page for more information about the git revert command. Also, look at this answer for more information about reverting commits.
Comment

PREVIOUS NEXT
Code Example
Shell :: git request-pull 
Shell :: windows shell 
Shell :: tar-delete 
Shell :: ffmpeg green screen 
Shell :: how to download nessus to kali debian 64 bit vm 
Shell :: powershell command shutdown computer 
Shell :: install pup command mac 
Shell :: change default boot grub 
Shell :: how to take a screenshot linux terminal 
Shell :: ssh codecommit 
Shell :: cli50 
Shell :: command to change user ID 
Shell :: uninstall g2o 
Shell :: linux command to show memory hardware 
Shell :: git clone 
Shell :: install gitlab-ce on centos 
Shell :: git undo all changes 
Shell :: decrypt user password linux 
Shell :: ansible skip tag 
Shell :: bash log function 
Shell :: how to create a shortcut in ubuntu 
Shell :: View Commit History With Changes in git command 
Shell :: how to make ngrok not expired 
Shell :: login to docker registry from terminal 
Shell :: find index of string in shell 
Shell :: how to use git stash in current branch 
Shell :: present working directory linux command 
Shell :: linux ubuntu update time 
Shell :: how to access the local machine using WSL 
Shell :: bash script cheat sheet 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =