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,170 points
32 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,060 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
• 58,990 points
338 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,060 points
274 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,060 points
117 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,060 points
48 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
943 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,060 points
44 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 in Git & GitHub by MD
• 95,060 points
58 views