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
• 16,300 points
710 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
• 42,330 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,880 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
72 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,870 points
49 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,870 points
60 views
+13 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,380 points
213 views
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,110 points
146 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
• 42,330 points
81 views