Tuesday 24 April 2012

Git branches

This is most certainly one of the most powerful features in git compared to tradition CVS/SVN systems.

1. you can branch locally, without affecting the remote directory - that's very cool
2. as we will see in later posts you can either merge or rebase your branch to the trunk (this defines the way your branch will get committed remotely: if you merge, you see the branch as a separate "path" in your remote repository, if you rebase, you can make sure your commit ends up looking like part of the trunk "path") - again very cool

So, here are the basics, use:
git branch
to view all current branches, the star indicates which branch you are currently working in
git branch BRANCH_NAME
to create a new branch
git checkout BRANCH_NAME
to start working in that branch
git checkout master
to revert to the master (main) branch
git merge BRANCH_NAME
to merge BRANCH_NAME into another branch (for instance master)
git rebase BRANCH_NAME
to rebase BRANCH_NAME into another branch (for instance master)
git branch -d BRANCH_NAME
to delete a given branch
git branch -D BRANCH_NAME
to force delete a branch
git checkout BRANCH_NAME

to checkout a branch and start (or continue) working on it
More information about the difference between merge and commit coming soon.
Thoughts?

No comments:

Online Marketing
Add blog to our blog directory blog search directory Blog Directory Blogarama - The Blog Directory