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.
Infos
- Git: http://http://git-scm.com/
- GitHub: https://www.github.com
- Linux kernel mailing list: http://marc.info/?l=linux-kernel&m=111314792424707
- Getting started with Git: http://git-scm.com/book/en/v2/Getting-Started-Git-Basics
- Gitk: http://gitk.sourceforge.net/
- Git beginners guide on conflicts: http://backlogtool.com/git-guide/en/intro/intro5_2.html
- Atlassian on Workflows: https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow
- Basic branching and merging: http://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging
- SUSE documentation: http://www.suse.com/documentation
« Previous 1 2 3
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
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.
News
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs