Getting started with Git

Pull Requests and Gitflow

As you can see, Git does not enforce a special way of working, nor does it impose certain tools. Users working with Git can choose their own process. If you want, you can limit yourself to work only in the master branch, never fork, or work only locally or as a single user.

Over time, Git projects have tended to fall into a few basic design prototypes, known as workflows, that deserve mention.

One important workflow is the so-called Review Branch workflow. Incremental features are added to their own branches, which are reviewed by experts before getting merged back to the main branch. Of course, a central repository is necessary for this task. If you want to work like the Linux kernel developers, you should define a unique, benevolent dictator: the leader will assign lieutenants and sub-lieutenants to review changes.

When you're working with platforms like GitHub, so-called pull requests inform other users that you'd like to have your changes go into another branch and that somebody who is allowed to commit for that branch should have a look.

The Feature Branch workflow separates development from the main branch. A developer who has a separate workspace can file a pull request to get any changes back into the master branch.

A typical workflow would start with:

git checkout -b new-feature master

The -b creates a new branch and sets the new branch as the place where the developer will work. After the pull request, a final git pull origin new-feature merges the feature branch back to the master. (The git pull command has a merge command built into it.)

The Gitflow workflow is considered a little more complicated than the other models I've described so far. In Gitflow, the branches that developers work in are more persistent.

Whereas in classical workflows, the branch sort of ends when a pull request is accepted and the branch is merged, Gitflow has a branch structure of its own. The master branch is the official branch, and the develop branch is the root or parent for the feature branches. Features are merged to develop. Only when develop has collected enough features, or a deadline approaches, will it be merged into the master, and probably be given a new version number. The process shown in Figure 5 actually represents the Gitflow workflow.

And You?

Git is flexible and does not force you into prescribed behaviors. You have many options for how to organize your projects. Developers are successfully interacting through their own workflows to produce high-quality software with Git. And Git isn't just for programmers. You can use Git to manage revisions of other types of documents. For instance, the SUSE documentation team chose Git (with the Gitflow workflow) to keep track of thousands of pages of product documentation stored in Docbook XML files that is updated regularly [9]. Once acquainted with Git, you will surely find your own workflow.

The Author

Markus Feilner is a seasoned Linux expert from Regensburg, Germany. He has been working with free and open source software since 1994, as a trainer, consultant, author and journalist. The Conch diplomat, Minister of the Universal Life Church, and Jedi Knight and owner of lunar property is employed as Team Lead of the SUSE Documentation Team in Nuremberg.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Branch Management

    Git makes version control as simple as possible. To manage your Git branches successfully, you need to learn the ins and outs of git branch and git merge.

  • Git Ready

    If you develop open source software, you need to know how to use Git. Information on Git fills books, but this basic overview will get you started with a vital open source development tool.

  • Remote Git Repositories

    Software projects often comprise several code branches, some of which exist in parallel. Git supports community code development through remote repositories and code branching.

  • Tree View

    Complex Git projects sometimes require a better view of the dependencies and branches. Several tools offer GUI options for Git. We take a look at gitk, gitg, git-gui, and GitAhead.

  • Git 101

    When several people collaborate on source code or documents, things can get messy fast. Git provides a quick cure: The distributed versioning system reliably ensures the integrity and consistency of data with minimal effort.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News