In this short article, I'll demonstrate the typical workflow for using a Git topic branch. If you've never heard of a topic branch, here's a description from the excellent book, Pro Git:
"A topic branch is a short-lived branch that you create and use for a single particular feature or related work.
This is something you’ve likely never done with a VCS before because it’s generally too expensive to create and merge branches. But in Git it’s common to create, work on, merge, and delete branches several times a day."
The basic Git topic branch pattern looks like this:
create a new branch (our 'topic branch') $ git branch bug1945 switch to the new branch $ git checkout bug1945 do your work on the branch ... commit your changes $ git commit -a -m 'fixed bug 1945' merge the changes back to the master $ git checkout master $ get merge bug1945 delete your topic branch $ git branch -d bug1945 create another topic branch ...
That's all there is to the basic Git topic branch workflow/pattern. Here's a quick review:
Here's a short list of Git commands related to the concept of topic branches:
create a branch and check it out in one step $ git checkout -b bug1945 list your current branches $ git branch a little more information about the current branches $ git branch -v use the gui merge tool to see your merges $ git mergetool
In summary, I hope this short tutorial on the concept of the Git topic branch workflow has been helpful.
Reporting live from Boulder, Colorado, this is Alvin Alexander. To keep up with my new tutorials, here's a link to the devdaily.com RSS feed, and here's a link to me on Twitter.
Post new comment