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!

Wednesday 15 September 2010

Beginner's guide to : Create a Git branch

Lets say you want to have a working branch, here's what you need to do.
On your local (automatically added to your remote repo):

$ git push origin master:refs/heads/branchName
e.g.: git push origin master:refs/heads/mybranchname

means that you will create a new branch named 'mybranchname' to the remote repository, copying everything from master.



Next step :

$ git checkout branchName
e.g.: git checkout mybranchname

moving, fetch, and start to work on branch 'mybranchname'



Enjoy!