15

Possible Duplicate:
Undo “git add”?

I made the mistake of running:

git add .

Which added important things such as .bashrc. Even though I run:

git rm .

When I run:

git push project master

Everything still is added. I've even reinstalled git, but I am still pestered by this. A solution I found was to start over and remove all the files from the commit. Are there any other things I could do to remove all the files from the commit?

1
  • By the way, the "hard" way to solve it wouldn't have been re-installing git but deleting (rm -rf) your repository folder and cloning it again (assuming it's a clone of a remote repo). Commented Nov 16, 2010 at 2:18

2 Answers 2

19

You can use git reset to unstage changes, or even git reset --hard HEAD~ to blow away the most recent commit (careful with that one, it will not even keep your changes around.)

See http://git-scm.com/docs/git-reset

2
  • It doesn't work. How I know that is I ran git log --pretty=format: --name-status | cut -f2- | sort -u and it still displayed all of the files. Commented Nov 16, 2010 at 2:22
  • If your changes get pushed you've already committed them. Commented Nov 16, 2010 at 2:26
10

Use git reset.

Not the answer you're looking for? Browse other questions tagged or ask your own question.