How to undo the most recent local commits in Git

0 votes

Hi Team,

I am new to Git. I accidentally did one commit in Git. How can I undo that commit in Git?

Dec 21, 2020 in Git & GitHub by akhtar
• 38,260 points
594 views

1 answer to this question.

0 votes

Hi@akhtar,

There is one way available to undo the commits. You can follow the below steps one by one.

$ git commit -m "Accidentally commit"
$ git reset HEAD~     
<< edit files as necessary >>        
$ git add .                             
$ git commit -c ORIG_HEAD  
answered Dec 21, 2020 by MD
• 95,460 points

Related Questions In Git & GitHub

0 votes
2 answers

How to view the nested workflow of a local git repository?

The closest way to view branches in ...READ MORE

answered Aug 2, 2019 in Git & GitHub by Sirajul
• 59,230 points
1,578 views
0 votes
1 answer

How to configure git send-email in local system?

Hi@akhtar, To use git send-email service you have ...READ MORE

answered May 4, 2020 in Git & GitHub by MD
• 95,460 points
2,350 views
0 votes
1 answer

How to create branch in GitHub from my local Git repo?

Hi@akhtar, To sync your existing branch in GitHub, ...READ MORE

answered May 7, 2020 in Git & GitHub by MD
• 95,460 points
871 views
0 votes
1 answer

How to install Git in the Ubuntu system?

Hi@akhtar, In the Ubuntu system, you can use ...READ MORE

answered Nov 19, 2020 in Git & GitHub by MD
• 95,460 points
663 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,995 views
+2 votes
1 answer
0 votes
1 answer

How to move the most recent commits to a new branch with Git?

Hi@akhtar, If you want to move your commits ...READ MORE

answered Dec 22, 2020 in Git & GitHub by MD
• 95,460 points
799 views
0 votes
1 answer

How to undo pushed commits in Git?

Hi@akhtar, You can revert individual commits with: git revert ...READ MORE

answered Jan 4, 2021 in Git & GitHub by MD
• 95,460 points
668 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP