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
-
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
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.