• Home
  • Subscribe
  • Contribute Us
    • Share Your Interview Experience
  • Contact Us
  • About
    • About CSEstack
    • Campus Ambassador
  • Forum & Discus
  • Tools for Geek
  • LeaderBoard
CSEstack

What do you want to Learn Today?

  • Programming
    • Tutorial- C/C++
    • Tutorial- Django
    • Tutorial- Git
    • Tutorial- HTML & CSS
    • Tutorial- Java
    • Tutorial- MySQL
    • Tutorial- Python
    • Competitive Coding Challenges
  • CSE Subject
    • (CD) Compiler Design
    • (CN) Computer Network
    • (COA) Computer Organization & Architecture
    • (DBMS) Database Management System
    • (DS) Data Structure
    • (OS) Operating System
    • (ToA) Theory of Automata
    • (WT) Web Technology
  • Interview Questions
    • Interview Questions- Company Wise
    • Interview Questions- Coding Round
    • Interview Questions- Python
    • Interview Questions- REST API
    • Interview Questions- Web Scraping
    • Interview Questions- HR Round
    • Aptitude Preparation Guide
  • GATE 2022
  • Linux
  • Trend
    • Full Stack Development
    • Artificial Intelligence (AI)
    • BigData
    • Cloud Computing
    • Machine Learning (ML)
  • Write for Us
    • Submit Article
    • Submit Source Code or Program
    • Share Your Interview Experience
  • Tools
    • IDE
    • CV Builder
    • Other Tools …
  • Jobs

How to Revert Git Commit already Pushed to Remote Repo?

Aniruddha Chaudhari/8892/0
git

Did you committed and pushed the wrong changes to your remote Git repo?

No worries. This happens many times with many of us.

In this tutorial, I will demonstrate how you can revert git commit that has already pushed to the remote repo.

I assume you have a basic understanding of the Git like what is Git commit, branch, checking out to the branch locally?

If you are new to the Git, you can follow the complete Git tutorial.

Now, let’s follow the steps to revert git commit.

It’s just a two-steps process to undo the commit. But, execute them carefully to avoid any further wrongdoing.

git tutorial

Step 1: Revert the Committed Changes Locally

For this, you need the commit ID. Every commit has a commit ID. With this commit ID, you can revert your changes back.

Here is the syntax of the git revert command.

git revert <commit_id>

It will create the new commit by deleting all the changes that had gone as part of the commit.

As of now, all the reverted changes are locally present. You need to push them to the remote repository.

Step 2: Push the Commit to Remote Repo

Here is the git command to push the local changes to the remote repository.

git push origin <branch_name>

Make sure you give the correct branch name.

That’s all.

You can log in to your remote repository. Look into the commit list or the code changes. You have reverted changes that you had made as a part of the wrong commit.

Do you have any questions or any challenges executing the command to revert git commit? Let me know by commenting below. Stay tuned for more Git tutorials.

git
Aniruddha Chaudhari
I am complete Python Nut, love Linux and vim as an editor. I hold a Master of Computer Science from NIT Trichy. I dabble in C/C++, Java too. I keep sharing my coding knowledge and my own experience on CSEstack.org portal.

Your name can also be listed here. Got a tip? Submit it here to become an CSEstack author.

Leave a Reply Cancel reply

Git Tutorial

Git- Introduction

Git- What is Code Repository?

Git- About GitHub

Git- Installation

Git- Essential Git Commands

1. Configuring Git

2. Initializing Git

3. Git Clone

4. Git Checkout

5. Git Add

6. Git Status

7. Git Commit

8. Git Push

9. Git Merge without missing changes

10. Git Revert Commit

Git- Interview Questions

Git Setup

Git- Setup on Ubuntu

© 2022 – CSEstack.org. All Rights Reserved.

  • Home
  • Subscribe
  • Contribute Us
    • Share Your Interview Experience
  • Contact Us
  • About
    • About CSEstack
    • Campus Ambassador
  • Forum & Discus
  • Tools for Geek
  • LeaderBoard