Sunday 19 September 2010

Beginner's guide to : Unstaging committed files on Git

For example, we have this below :

$ git status
# On branch tryone
# Changes to be committed:
#   (use "git reset HEAD ..." to unstage)
#
# new file:   config/database.yml
# new file:   log/development.log
# new file:   log/production.log
# new file:   log/server.log
# new file:   log/test.log

and we have a change of mind about committing log/test.log, we want it off the list, we don't want the changes on it to be committed further more to be saved on the remote repository. So what we need to do is to run this line below:

$ git reset log/test.log

Voila! it's done! check it out with git status and you'll have log/test.log no longer on the list.

Btw, those mentioned above works on removing single added file, or, if you're in the mood of listing the files (after HEAD) you can do multiple remove, but if removing all added files (uncommitted ones) do this below instead :

$ git reset

'Enjoy!

No comments:

Post a Comment