Showing posts with label git checkout. Show all posts
Showing posts with label git checkout. Show all posts

Saturday, 16 October 2010

Beginner's guide to : Remove uncommitted changes in Git

Our case is, somewhat below :

(1) Remove changes on specific file.
(2) Remove all changes we made.

What we want is to get into the previous state, before we started to tinker with it.
We need to run this below for case (1) :

$ git checkout filename

And here below, to remove EVERY changes made :

$ git reset --hard HEAD || $ git reset --hard

(tips HEAD = last, HEAD^ = next to last, HEAD~2 = last - 2, and so on)

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!