element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Community Hub
Community Hub
Member Blogs Firmware Version Control with GitHub part 1: Branch Strategy for New Features
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Leaderboard
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Community Hub to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 8 May 2020 10:09 AM Date Created
  • Views 4821 views
  • Likes 11 likes
  • Comments 21 comments
  • tutorial
  • github
  • version_control
  • learning
  • git
  • gitlab
  • github_repository
Related
Recommended

Firmware Version Control with GitHub part 1: Branch Strategy for New Features

Jan Cumps
Jan Cumps
8 May 2020

image

 

A possible strategy for using GIT and working with branches.

In this part 1: working on new developments.

In part 2: bug fixes on the released code

image

I am suggesting a GitHub process, but it translates to other platforms with pull request support, E.g.: Azure DevOps, GitLab, Bitbucket, ...

The examples are using the repository of the eLoad.

I am using a single repository but it works virtually the same if contributors work from their own forked repository.

 

 

Branch Strategy Principles

 

Single Branch

You can work with a single branch. Git always comes with a default master branch.

If all you want to do is have a version controlled repository, you can give commit access to all contributors and that's that.

No need to read any further. You're good image.

 

image

In the images, the vertical lines represent Git branches. The horizontal arrows are actions.

 

Feature Branches

If you want to control what goes into the master (or any meaningful) branch, you can use the feature branch strategy.

In that case, you allow contributors to create their own branches on the fly*2. You don't give them commit access to the master branch.

Feature branches are short-lived by design. They are meant to work on one aspect of the software.

The developer works in that branch and has all the advantages of version control. Changes are tracked, but they stay safely in that feature branch.

It doesn't matter if non-working or partial code is checked in. The "official" code base is not impacted.

 

Once development is deemed finished - you can set rules here if wanted, like all test cases passed, code style checks passed, .... - the developer can create a pull request.

This is where the hosting site matters*1. They support this process to generate the request and get it merged into the official branch.

Once the repository admins accept that pull request, the feature branch is typically deleted because it has lived its life. No need to keep that.

The change will be eternally traceable via the pull request that stays in the repository forever.

 

Branch Policy

The hosting platforms all have some way to set the rules for branches.

You can set who can commit / merge, what type of merges are allowed, who's approval is needed, or no rules at all (typical for feature branches).

If you want your master branch managed, then restrict commit, and set at least one approver.

A pull request creator should not be able to accept their own changes.

This will take care that no one can directly write into the managed branch, and everything can be reviewed and accepted before merging features.

 

image

If you have an unpopular open source project and you're the only contributor, you can still use this approach, but enable "admin override".

In that case you can accept your own pull requests. Not an issue because it's your repository. You're the boss. You do as you please.

 

Project / Development Branch

When you want a stable master branch that represents the official released code, and you have active development going on, then there's the possibility to create long living additional managed branches.

The development branch starts as a clone from the master.

You'd want to set up a policy for such a branch too, similar as the master branch.

Then developers will create feature branches based on that development branch, not the master.

Their process is the same as explained in the Feature Branch section, while they are developing inside that feature branch.

But once done, they create a pull request to the development branch. Not to the master branch.

When the admin approves the request, code is merged into the development / project branch and the feature branch is deleted. Job done.

The repository admin should not accept direct pushes from such a feature branch into master.

 

At release time, the release manager (or you if you are lonely) will create a pull request with the development / project branch changes to the master branch.

Once the repository admin accepts that request, this is the new released version.

 

image

 

You can have several managed development / project branches in a complex project.

Just keep in min that everyone needs to understand what branch is for what, who manages it and where the results should flow to.

My advise is to start simple. And if that simple approach works, don't make it more complex.

Only if you can't manage the contributions in a simple way, then add. See my last line in the Single Branch section for a similar advice.

 

 

In the next part I'll add an approach to allow bug fixes in the master branch. Managed, and with a solution to integrate them in the development branch.

Comments and critiques are very welcome. There are better approaches than mine.

 

 

 

 

*1: or doesn't matter - if you use Git's own mechanism to create patches and mail notifications to request merge.

That approach is not the subject of this post. I want to document the process with pull management.

 

*2: in open source projects, it's common to have everyone run their own fork, instead of allowing the contributors to create branches in your account.

Everything works similar as here. They can create pull requests from such a forked repository into (one of our) branches.

Advantages:

  • you don't have to create and manage users. And several of the suggested repository hosts have a limit on their free tier.
  • The contributor can have their own strategy and approach. You aren't impacted by how they manage the code.
    The only thing you see is a pull request, just like one from a local feature branch.

Some of the hosts have project / issue management to assist the discussion with the contributors.

 

Related Blog
Firmware Version Control with GitHub part 1: Branch Strategy for New Features
Firmware Version Control with GitHub part 2: Branch Strategy for Bug Fixes
Firmware Release with GitHub: Branch, Issue, Pull Request and Project support
Fix a Bug in Production with GitHub: Issue, Branch, Project and (Draft) Pull Request supported + Eclipse Git Plug-in
Break-Fix with GitHub: part two: push bug fixes to the development team
GitHub and GIT: sign your commits with a certificate
GIT course
  • Sign in to reply

Top Comments

  • colporteur
    colporteur over 5 years ago in reply to Jan Cumps +3
    Jan Cumps I'm willing to take your scratch pad notes and drawing and convert them to vector drawings (Inkscape) if you are interested? I have a few cycles now that my RoadTest review The Road to Raspberry…
  • Jan Cumps
    Jan Cumps over 5 years ago in reply to colporteur +3
    yes, everything I post on the community is open - feel free to copy or alter. If you're looking for a cleaner drawing, the link I posted in the previous comment has a different and more organised drawing…
  • colporteur
    colporteur over 5 years ago in reply to Jan Cumps +2
    It was a philanthropic offer to lighten a perceived burden. I was thinking that this was part of a larger project for publication within the E14 Community. If you had a need I am willing to create the…
  • Jan Cumps
    Jan Cumps over 5 years ago in reply to Workshopshed +2
    Yes, you can plug in automated build. Automated test scenario run. Automated review against coding standards. All of these are wins. And the effort to achieve those lowers significantly if you actually…
  • Jan Cumps
    Jan Cumps over 5 years ago in reply to Workshopshed +2
    My claim to fame is an mid-2000 unit test project for ERP developers - with CVS at the time, but the process was agile - not at all tied to a version control system Downloaded 20.000 times. Used in commercial…
  • Jan Cumps
    Jan Cumps over 5 years ago +1
    For a full-fledged approach: https://nvie.com/posts/a-successful-git-branching-model/
  • Jan Cumps
    Jan Cumps over 5 years ago +1
    What I haven't discussed here is that GitHub also has "SCRUM board" style project support: The task here is attached both to an "issue" that supports this work .... ... and the related pull request(s)…
  • Workshopshed
    Workshopshed over 5 years ago +1
    Interesting to see embedded development using these techniques. I saw a talk from Arm the other week about CI and automated testing which is something you can do once you start using tools like git.
  • yuricts
    yuricts over 5 years ago in reply to colporteur +1
    Personally I prefer using the console commands for git... I do acknowledge that sometimes it is nice to see graphical interfaces with branches and all, but using the command line just gives me a better…
  • shabaz
    shabaz over 5 years ago in reply to colporteur +1
    Hi Sean, I use Visual Code with Git, however I'm conscious that if I move to a different IDE/editor then I'd need to learn the commands! So it's good to know the command-line syntax, but I don't know it…
Parents
  • Andrew J
    Andrew J over 5 years ago

    Hi Jan,

     

    I'm not that familiar with git although I have used it.  Rather than the command line I'm using GitKraken and what you are blogging here seems to match to gitflow which is directly integrated into GitKraken.

     

    (This isn't a question about Gitkraken but git!)

    When I activate that integration it ensures that I have two branches to start from: master and development on local.  This is where it would appear to differ from your manual approach - development is not a clone of master.  In trying this workflow out, I created a hot fix - which created a branch, hotfix, from master - and when I committed and 'finished', it merged hotfix into master and development, and deleted the hotfix branch, all on local repository. Pushing to remote I can see the commit and the version tag created (but not the development branch.)  Reading up about gitflow, it seems to me that development branch should be a clone of master as all 'dev' work, apart from hot fixes, is originated from that branch.  Does that seem right to you?  If so, is there a way of getting development branch to match master - rebase master on development - or is that not necessary?  I would expect to push changes on development to remote but perhaps development always stays on local and never goes to remote.

     

    Hopefully, I've asked this the right way, I'm still getting my head around the terminology and right way of working!!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 5 years ago in reply to Andrew J

    Have you ever pushed and committed the development branch that Kraken generates for you?

    If you do that, it should appear upstream too.

    The same for your temporary feature branch.

    I checked Kraken website and the stream they use is very similar to what I use. Both they and I based many aspects on this blog post: https://nvie.com/posts/a-successful-git-branching-model/

     

     

    Almost all combinations are possible. I suggested one because it's easier to work if you have a known way of working.

    But there are other very good approaches.

    What you source your development branch from is something you decide yourself. I propose to source it from the master code. But it's a proposed way of working. Something that fits projects that already have a code base.

    I can see a valid situation if you start from an empty slate, to not have anything in master yet, and start your first commits in Develop and the feature branches based on develop, until you have a first release.

     

     

    A few scattered remarks:

    • I also see you mention gitflow. Do you mean the product gitflow? If yes, their workflow is also similar to what I propose here, but they offer richer commands.
    • I'd not work with local branches that have no server mirror. I have seen other people do it, and the GIT tutorials explain that. But I see it as a team tool - with all activity available to everyone by having all branches, also temporary ones, on the server.
    • Start with the command line if you want to understand git and github. Make a play github project, and start repeating the steps to get a local version, branching, etc, from your computer's prompt.
      You'll learn it in one focused day by cloning, branching, merging, pushing, committing. Because it tells you what it's doing in detail while executing the code.  When done, you can delete the github repo and your local playground.
      The Gui will make more sense then, because from what I see it's made to support a similar process.
    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Andrew J
    Andrew J over 5 years ago in reply to Jan Cumps

    I have played around with the command line in the past so I have a reasonable basic understanding.  gitflow is the 'product' gitflow - I assume that under the covers GitKraken is running commands such as "git flow release..."  From what I could tell, it automates the process you describe but it doesn't seem to use Pull Requests as the one major difference.  Certainly its branching strategy appears to be the same.

     

    Development hasn't pushed up to remote so that's something to check out in the morning; I'd assumed that 'pushing' to remote would push all differences but clearly not.  Thinking about it a bit more over dinner, I realise my question was based on a bit of misunderstanding - i.e. the development branch wouldn't normally be a full clone of master.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • Andrew J
    Andrew J over 5 years ago in reply to Jan Cumps

    I have played around with the command line in the past so I have a reasonable basic understanding.  gitflow is the 'product' gitflow - I assume that under the covers GitKraken is running commands such as "git flow release..."  From what I could tell, it automates the process you describe but it doesn't seem to use Pull Requests as the one major difference.  Certainly its branching strategy appears to be the same.

     

    Development hasn't pushed up to remote so that's something to check out in the morning; I'd assumed that 'pushing' to remote would push all differences but clearly not.  Thinking about it a bit more over dinner, I realise my question was based on a bit of misunderstanding - i.e. the development branch wouldn't normally be a full clone of master.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube