How to delete committed message from local and remote repository in git

Today I wanted to commit some message on development branch, and push it to development branch on the remote git repository, but mistakenly I did modified code on master branch, committed and also pushed it to remote master branch. But since, I didn’t wanted to touch the master branch and do all work on development branch, now I am at problem and wanted to remove all traces of changes I did to master branch. This is how, I did it.

$ cd my_source
$ git branch
This is to make sure we are on right branch.

$ git reset HEAD^ –hard
This git command will delete the last commit from the current branch.

$ git push origin –all -f

This will now force push the changes I did on local repo to the remote repository, making sure it also deletes the changes I had pushed to remote branch.

Android Android Commands Android Java Applications Application Libraries Bash / Shell Scripts Bluetooth driver Build Frameworks Commands and Packages Core Kernel C Programs Development Environment Setup Documents / Books Errors & Failures File Systems Framebuffer / Display Driver git Go Language Programs Hardware Platforms Home JAVA Programs Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL NDK / Middleware / HAL Network Driver OS Concepts PHP Procfs Filesystem Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded
Tags:

Leave a Reply