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,352 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,350 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,040 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,380 points
263 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,380 points
12,025 views
0 votes
0 answers
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,690 points
1,395 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
2,054 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,273 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,350 points
373 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