+6 votes
1 view
in Devops and Agile by (20k 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

+7 votes
by (28.4k 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

 

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...