Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+5 votes
2 views
in DevOps and Agile by (19.4k points)
edited by

I mistakenly added files to git using the command:

git add myfile.txt

I have not yet run git commit. Is there a way to undo this, so these files won't be included in the commit?

1 Answer

+6 votes
by (27.5k points)
edited by

Since you have not committed yet, undoing a file that is already been added is quite easy task in git.

Now, say I want to reset my file 'myfile.txt' which is already been added, I will use this command:

git reset HEAD myfile.txt

For better understanding about these commands go through the following crash course on git that will help you to understand git well

 

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...