Quantcast
Channel: How can I undo my last git add - Stack Overflow
Viewing all articles
Browse latest Browse all 3

How can I undo my last git add

$
0
0

Just curious to know. Say I have one file named test, I add Hello World\n to the file and git add it.

Now in the staging area, there should be a file named test with content Hello World\n.

Now I add another line Hello World 2\n and then git add it.

Now my staging area would be file test with its content as "Hello World\nHello World2\n".

Now is there any way that I undo my second git-add to make the staging area back to file test with content "Hello World\n".

Assumptions: There may or may not be any commits at this time. Please consider two conditions.

Additions: What if there are multiple git-add and I want to undo the last n times of them.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images