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 Application Stack / User Interface Bash / Shell Scripts Commands and Packages Compilation Content Management System - CMS Core Kernel C Programs Development & Build Development Environment Setup Errors & Failures Flutter git Go Language Programs Hardware Platforms HTML JAVA Programs Kernel & Device Drivers Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Monetization / Google AdSense NDK / Middleware / HAL OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized User Interface Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply / Ask Question