undo git add before commit

+1 vote

I’ve added a few files using the command git add file.txt with the intension of committing it in my github repo but now I’ve changed my mind and want to undo the add. Is there a way for this?

I haven’t committed it yet.

Aug 17, 2018 in Git & GitHub by Hannah
• 18,570 points
2,806 views

2 answers to this question.

0 votes

You use the command

git reset <file>

in your case it’ll be

git reset file.txt

You can use

git reset

without any file name to unstage all due changes.

answered Aug 17, 2018 by Kalgi
• 52,360 points
0 votes
git status

git will tell you what is staged, etc, including instructions on how to unstage:

use "git reset HEAD <file>..." to unstage
answered Aug 20, 2018 by Nilesh
• 7,050 points

edited Dec 21, 2020 by MD

Related Questions In Git & GitHub

+1 vote
1 answer

why we need to add at staging area before commit??

Hi@akhtar, The staging area is like a rough draft space, ...READ MORE

answered Jul 19, 2020 in Git & GitHub by MD
• 95,440 points
501 views
0 votes
1 answer

Please: Commit your changes or stash them before you can merge in Git.

Hi@akhtar, You can't merge with local modifications. Git ...READ MORE

answered Jan 4, 2021 in Git & GitHub by MD
• 95,440 points
18,223 views
0 votes
0 answers

How do I resolve git saying "Commit your changes or stash them before you can merge"?

I made some changes to my local ...READ MORE

May 13, 2022 in Git & GitHub by Kichu
• 19,050 points
864 views
0 votes
1 answer

How to solve the ‘Git commit -a error’?

This happens when no editor is set. ...READ MORE

answered Jul 5, 2018 in Git & GitHub by Tyrion anex
• 8,700 points
2,041 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,508 views
+2 votes
1 answer
0 votes
3 answers

Change commit message after committing and before push.

You also can use git filter-branch for that. git filter-branch ...READ MORE

answered Sep 6, 2018 in Git & GitHub by lina
• 8,220 points
1,825 views
+1 vote
2 answers

Git Commands

This command basically adds all your changes ...READ MORE

answered Aug 14, 2018 in Git & GitHub by Kalgi
• 52,360 points
747 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