undo git add before commit

0 votes

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
• 14,080 points
461 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
• 37,320 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
• 6,900 points

Related Questions In Git & GitHub

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,280 points
37 views
0 votes
1 answer

How to forcefully commit a file to Git even if the file is ruled as unchanged?

This is simple, just follow the below ...READ MORE

answered Jul 11, 2018 in Git & GitHub by Sophie may
• 9,430 points
26 views
0 votes
1 answer

Why is Git commit not functioning with Git Bash?

This occurs because you might have git ...READ MORE

answered Aug 7, 2018 in Git & GitHub by Sophie may
• 9,430 points
37 views
+13 votes
2 answers
0 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,100 points
89 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
• 37,320 points
45 views