Skip to content

Git 2.4 — atomic pushes, push to deploy, and more

Git's 10-year birthday celebrations notwithstanding, the Git community has been busy preparing another major new release of the Git command-line utility. Release 2.4.0 is weighted towards cleanups, bug fixes, and other small improvements, but here we would like to take a moment to highlight a few new features that you might find useful.

Atomic pushes

Until now, when you tried to push multiple branches to a remote Git server, some of the updates might have succeeded while others failed. For example, somebody else might have pushed to one of the branches, meaning that you have to reconcile your changes with theirs and try pushing that branch again.

But for some purposes you might want to push a set of reference changes atomically, meaning that either all of the reference updates are accepted, or none of them are. Now that is possible, using the new --atomic option to git push:

$ git push --atomic origin branch1 branch2 ...

This feature is probably most useful for automated tools. Suppose you have a tool that runs continuous integration on a branch, and if the test succeeds it merges the branch to master, creates a new tag, and adds a note to the commit. All three things can be pushed at the same time using

$ git push --atomic origin master refs/tags/release-17 refs/notes/test-results

The --atomic option guarantees that either all three references will be updated on the remote, or none of them will.

Please note that git push --atomic is still somewhat experimental, and it is possible to experience partial updates if you try to push something unusual. But if you use --atomic, the most common reason for a reference update to be rejected — the dreaded "non-fast-forward" update — will no longer leave your push half-accepted, half-rejected. [source]

Push-to-deploy improvements

The last major Git release, Git 2.3, introduced the ability to push directly to a branch that is checked out on a remote Git server, making it an easy way to deploy a new version of a website just by pushing. (But please read our last Git release blog post to learn about some caveats that apply to this approach.)

Git 2.4 improves push-to-deploy in two ways:

  • There is now a push-to-checkout hook, which can be installed on the server to customize exactly what happens when a user pushes to the checked-out branch. For example, by default such a push fails if there have been any changes to the working tree on the server. The push-to-checkout hook could instead try to merge any server-side edits with the new branch contents, or it could unconditionally overwrite any local changes with a pristine copy of the pushed branch contents. [source]

  • Push-to-deploy formerly didn't work correctly when pushing to a server that is on an "unborn branch". (An "unborn branch" is what Git calls a branch that doesn't yet have any commits on it, as for example immediately after a Git repository is initialized.) Now this works as expected, which will hopefully reduce confusion for users who are trying to set up push-to-deploy for a new project. [source]

Inverted grep for logs

git log is a very powerful command, with a bewildering variety of options. One class of useful options includes --grep=<pattern>, --author=<pattern>, --committer=<pattern>, and --grep-reflog=<pattern>, which limit the output to commits whose commit message, author, committer, or reflog entry, respectively, matches the specified regular expression pattern.

There is a new option, --invert-grep, that inverts the sense of the other pattern-matching options. When this option is used, git log lists the commits that don't match the specified pattern(s). For example, to search for merge commits that do not include a "Fixes" annotation in their commit messages, you could run

$ git log --all --merges --invert-grep --grep=Fixes

[source]

Advanced usage

It is not possible to combine pattern-matching options into arbitrary expressions like "match A and B but not C" in a single git log command. But now, thanks to --invert-grep, you can do so by stringing commands together in pipelines, though it is a bit subtle. For example, suppose you want to find the non-merge commits in Git's master branch that were written by its maintainer, Junio Hamano, but are missing "Signed-off-by" lines:

$ git rev-list --no-merges --author="Junio C Hamano" master |
      git log --stdin --no-walk --invert-grep --grep='^Signed-off-by:'

Note that the first command uses git rev-list, which just lists the SHA-1s of matching commits rather than showing their commit messages etc. git rev-list takes many of the same options as git log. Its output is used as the input to a second command, which uses --stdin --no-walk to read commit SHA-1s from its standard input and only process those commits. (Without --no-walk, the second command would also process the ancestors of the commits passed to it.) The second command thus skips any commits that contain "Signed-off-by" lines, and outputs the rest.

It turns out that many of the commits listed by the previous command are "revert" commits, which don't really need Signed-off-by lines, so let's exclude revert commits and count how many are left:

$ git rev-list --no-merges --author="Junio C Hamano" master |
      git rev-list --stdin --no-walk --invert-grep --grep='^Signed-off-by:' |
      git rev-list --stdin --no-walk --invert-grep --grep='^Revert ' |
      wc -l
76

As you can see, it is possible to put together quite sophisticated queries using these building blocks.

Other minor improvements

  • git status now allows the --verbose option to be specified twice, in which case it shows the changes that have been staged but not yet committed and also the changes in the working tree that have yet to be staged. [source]

  • git log --decorate, which lists branch names alongside the usual log output, now shows not only the current HEAD, but also indicates which branch it currently points at, in the format (HEAD -> master). [source]

  • There is now a configuration setting push.followTags, to turn on git push's --follow-tags option by default. [source]

  • The HTTP-based transports now send Accept-Language headers when making requests. This opens the way to internationalizing the informational messages emitted by the Git server, though that effort has not yet begun. [source]

The rest of the iceberg

Aside from the highlights listed here, there have been myriad small improvements to Git since version 2.3.0 — over 400 commits in all, by 76 different contributors. For full details, see the Git 2.4.0 release notes. Or, even better, view the commits using Git itself:

$ git clone https://github.com/git/git.git
$ cd git
$ git log --oneline --graph v2.3.0..v2.4.0

Looking to level up your Git game? Browse the docs on the main Git website, grab a copy of Pro Git, or read GitHub's Guide to setting up Git.

Happy collaborating!

Open source license usage on GitHub.com

Open source simply isn't open source without a proper license. Unless you've explicitly told others that they can modify and reuse your work, you've only showed others your code; you haven't shared it. Here at GitHub, we're big fans of open source, so we set out to better understand how our users approached licensing their code by looking at license usage across public, non-forked repositories, in hopes of encouraging more users to share their work with others.

Percentage of licensed repositories on GitHub.com

If you look at this graph of licensed repositories over time, you'll notice that the percentage of licensed repositories has been decreasing, hovering around 20% throughout GitHub's history (about 30% if you include forked repositories). The sharp spike in mid-2013 represents our first pass at making open source licensing on GitHub easier by launching choosealicense.com to demystify license choices, and introducing the license picker to encourage users to license their projects.

Breakdown of license usage

We also wanted to look at the relative breakdown of the most popular open source licenses. You can see their popularity expressed below as a percentage of licensed projects on GitHub.com:

Rank License % of projects
1 MIT 44.69%
2 Other 15.68%
3 GPLv2 12.96%
4 Apache 11.19%
5 GPLv3 8.88%
6 BSD 3-clause 4.53%
7 Unlicense 1.87%
8 BSD 2-clause 1.70%
9 LGPLv3 1.30%
10 AGPLv3 1.05%

Unsurprisingly, MIT, Apache, and GPL are the clear front runners, with some 15% of licensed projects opting for a non-standard license or standard license not among those listed on choosealicense.com.

License breakdown on github.com by repository creation date

Last, we looked at how license usage has changed over time. Again, you see a swift uptick of the three featured license (MIT, Apache, GPL) in mid-2013, with the relative percentages remaining otherwise steady over the past six years.

Developers use GitHub because they want to share their code with the world, and the data suggests that when the tools we use make it a little bit easier, developers do just that. When presented with the option, they choose to license, and they license very permissively.

Under the hood

To detect what license, if any, a project is licensed under, we used an open source Ruby gem called Licensee to compare the repository's LICENSE file to a short list of known licenses. However, it's important to note that this approach doesn't count a project as licensed if the README indicates a specific license or if individual project files contain a named license in the code comments.

The licenses API

We want to make it easier for open source developers to license their code, and for open source consumers to verify that they are using open source projects under an appropriate license. To that end, we're launching the Licenses API preview to retrieve information about a particular project's license file, as well as metadata about open source licenses in general.

When you pass the appropriate preview media type, API requests for a particular repository will now include the project's license, if any, represented by its SPDX-compliant and human-readable names:

{
  ...
  "license": {
    "key": "mit",
    "name": "MIT License",
    "url":  "https://api.github.com/licenses/mit"
  }
  ...
}

The individual license endpoints (e.g., /licenses/mit) return additional information about the license, including what you can and can't do with the software, and the full license body. For more information, see the developer documentation.

Share your code

If you haven't already, we encourage you to add a LICENSE file to your project. To make things a bit easier, if you begin to create a file named LICENSE via the web interface, we'll even provide you with a list of common license templates to choose from.

license dropdown

This is just the start. Look forward to a more in depth analysis over the coming weeks as to how license usage affects project success, as we delve deeper into the numbers. Of course, in the mean time, we encourage you to explore license usage on GitHub using the Licenses API.

Happy open source licensing!

The Dodgeball Tournament Returns!

The GitHub Charity Dodgeball tournament is back, and better than ever.

dodgeball winners

Details

Where? SoMa Recreaton Center 270 6th Street San Francisco, CA

When? Sunday, March 22, 1:00pm until 6:30pm

  • 1:00 to 1:30 - Sign in and warm up
  • 1:30 to 4:30 - Round Robin Tournament play
  • 4:45 to 6:00 - Single Elimination Round
  • 6:00 to 6:30 - Awards ceremony
  • 7:00 to 10:00 - After-party at GitHub HQ (88 Colin P Kelly Jr. Street, San Francisco).

Why? In 2013, 20 teams joined us to compete on the dodgeball court, all in the name of charity. Heroku prevailed for the second time and brought home the Octotrophy, but the real champions are those who received some of the $58,000 we raised!

We're headed back to SoMa Recreation Center and we're devoted to making this year's tournament the best yet. The buy-in to enter is $3,000, and all funds will be split among the charities.

How? We'll be using the World Dodgeball Society's rules for our 2015 tournament. Teams will need 10 players on court during gameplay, but can have up to 15 members per team to allow for player substitutions. Teams must have at most a 3:1 ratio of men to women.

Who? We will all be playing for four local charities. Donations are managed by Bright Funds.

  • Build BUILD's mission is to use entrepreneurship to excite and propel disengaged, low-income students through high school to college success. In 2002, BUILD became a key player in school districts when it went into local high schools and began offering its entrepreneurship curriculum as a daily, credited class. By working closely with the partner schools and their teachers, BUILD began supplementing students' traditional education with the real-life experience of running their own small businesses.

  • SF Public Library The SF Library system is pretty amazing. Not only are they one mega, open source of information and learning in the sense of lending books, music, etc., but they also have all kinds of others programs to support the community. It is also one of the few places people can go and use computers for free. Finally, it often doubles as safe space for at risk youth and the homeless population.

  • Second Harvest Food Bank Collects and distributes more than 1 million pounds of food throughout the Bay Area EACH WEEK. They are feeding thousands of families, many of which are struggling to pay high local rents, etc.

  • Glide Glide provides many kinds of services to anyone who needs them, from shelter, to healthcare, to overcoming violence.

Sign up here!

Questions? Send them to dodgeball@github.com

New Baby One-Pieces and Kid Tees in the Shop

Young and future coders rejoice! We've just merged a pull request for new baby one-pieces and kid tees.

Kids Shirts

Grab yours in the GitHub Shop

Octocat Holiday Ornament

For those of us in the United States, many of our families have collected White House holiday ornaments over the years. With the Octocat’s history of celebrating moments, we thought it would be fun to celebrate this holiday season with a limited edition Octocat Holiday Ornament of our own in the GitHub Shop.

ornament-blog-post

This Cyber Monday (December 1), take 25% off the new Octocat Holiday Ornament, Octocat Figurine, and the rest of the GitHub Shop with the code CYBERCAT2014.

Don’t forget, the last day to order for delivery by Christmas for international shipping using Priority Mail International shipping rate is December 8th and domestic shipping is December 18th.

New in the shop: Pinktocat 3.0 shirts

October is Breast Cancer Awareness Month, and to help the cause, we’re offering a new shirt in the GitHub Shop.

Pinktocat 3.0

All proceeds from the sales of this shirt will be donated to the American Cancer Society’s Making Strides Against Breast Cancer campaign. Join us in wearing your support.

New in the shop: GitHub Flow shirts

github-flow-shirt

Wear our new GitHub Flow shirt and show off how easy it is to merge pull requests with high fashion. Check it out in the GitHub Shop.

Octocat sticker packs are back...

... and stickier than ever!

Sticker packs

Now in the GitHub Shop: sticker packs with never-before-seen Octocats! Share them with your friends, and bring your laptop one Octocat sticker closer to greatness.

Octocat Glencairn glasses

If you're a fan of animated GIFs and GitHub, then you may have seen this one on the internet:

Glencairn glasses

At long last, you can now get your very own Octocat Glencairn glasses* in the GitHub shop!

To make room for new items like this one, we're saying farewell to the Octobiwan mug. The remaining supply will be marked down and sold until September. If there are any Octobiwan mugs left at that time, then we will donate them to charity. If you've been debating grabbing one, now is the time to do it!

* Infinite whisky not included.

Video from Passion Projects Talk #9 with Melissa Severini

Melissa Severini joined us in December of 2013 for the 9th installment of our Passion Projects talk series. Her talk explored the dynamics of managing humans in a startup environment and prepared us with tips for handling any emergency. Check out the full video of her talk and our panel discussion below.

Photos from the event

Thanks to everyone who came out for Melissa's talk, including our musical performance for the evening, Mara Hruby.

1506362_1455845864627428_1446930499_o 966490_1455845871294094_297428509_o 1501272_1455845951294086_1340688697_o 1492666_1455846054627409_770123872_o 857501_1455847357960612_862392046_o

1504400_1455846097960738_1466238186_o 1606434_1455846934627321_126472006_o 1496053_1455846551294026_733577178_o

Photos courtesy of our fab photog :sparkles: Mona Brooks :sparkles: of Mona Brooks Photography.

Video from 2013 Dodgeball Tournament

In November of 2013 we hosted our 3rd annual Dodgeball Tournament. With the help of the participating teams we raised money for 4 awesome non-profits. See the action from the tournament in the video below.

If you're interested in joining the next Dodgeball Tournament, send us an email to dodgeball@github.com.

Video from Passion Projects Talk #8 with Ligaya Tichy

Ligaya Tichy joined us in November of 2013 for the 8th installment of our Passion Projects talk series. Ligaya's talk inspired us all to give more charitably and left us with a concrete plan of action to get better at giving in 2014. Check out the full video of her talk and our panel discussion below.

Photos from the event

Thanks to everyone who came out for Ligaya's talk and made it a night to remember, including our house band for the evening, Emily Jane White.

passionproj_ligayatichy-3845 passionproj_ligayatichy-3914 passionproj_ligayatichy-4033 passionproj_ligayatichy-4045 passionproj_ligayatichy-4076 passionproj_ligayatichy-3941 passionproj_ligayatichy-4636 passionproj_ligayatichy-4069 passionproj_jenmyers-1761

Photos courtesy of our fab photog :sparkles: Mona Brooks :sparkles: of Mona Brooks Photography.

Video from Passion Projects Talk #6 with Leslie Bradshaw

Leslie Bradshaw joined us in September of 2013 for the sixth installment of our Passion Projects talk series. Leslie dropped some serious RealTalk™ about her career in tech, creating healthy work environments for the people we work with, and how to stay focused in a distraction-fueled industry. Check out the full video of her talk and our panel discussion below.

Photos from the event

Thank you to everyone who came out for Leslie's talk and made it an awesome night!

1 pp_lesliebradshaw-0097 3 2 8 7 6 11 12 14 13 1 9 10

Photos courtesy of our fab photog :sparkles: Mona Brooks :sparkles: of Mona Brooks Photography.

GitHub Game Off II Winners

We announced our second annual game jam, the GitHub Game Off II, back in October. Today, we're revealing the winners and giving you the chance to play and fork these great games!

All of our winners will receive shiny new iPad Airs, while runners up will enjoy some amazing :octocat: swag!

Transcube

Transcube

A 2d puzzle platformer based on the concept of transforming into different "blocks", with their unique properties, and making your way to the end of the level with the provided transformations » view the source · play

Swap

Swap

Swap is a new take on the classic tile-based puzzle game, where you change which character you're controlling to reach your goal » view the source · play

Psiral

Psiral

A turn based strategy game in which four wizards battle to reach the fountain of endless energy » view the source · play

Protocol 390

Protocol 390

To survive in People's Park, you must supply the prophet with change » view the source · play

Heal Em' All

Heal Em' All

Imagine, what if the cure exists? What if the zombie plague can be stopped? Explore old, abandoned graveyards, heal as many zombies as you can, and find your way out. But be careful not to become one of them! » view the source · play

Runners Up

CHANG€

CHANG€

An intense game about the extreme life of supermarket cashiers » view the source · play

Color Quest

Color Quest

An infinite runner following a black and white pixel's quest to change into a color pixel » view the source · play

Room For Change

Room For Change

RfC is a randomly generated action RPG. You play as a chubby archeologist who is tasked with retrieving three sacred artifacts from the pyramid of the legendary Pharaohs » view the source · play

Custom Tetris

Custom Tetris

Play the classic Tetris game the way you like it! Adjust the rules, change the sides » view the source · play

Hyperspace Garbage Collection

Hyperspace Garbage Collection

General Hyperspace Waste Management Solutions » view the source · play

MEGA GIRL.git

MEGA GIRL.git

Megaman inspired game » view the source · play

BitBot

BitBot

An HTML/JS game where you control a bot, which must sense, plan, and act » view the source · play

Jekyll & Hyde Collide

Jekyll & Hyde Collide

A multi-layered infinite side-scroller » view the source · play

Chromacore

Chromacore

2D musical platformer set in a dark, black & white world that progressively becomes more colorful and happy through successful gameplay » view the source · play

Turkey Cooking Simulator

Turkey Cooking Simulator

Literally, a turkey cooking simulator » view the source · play


Thank you to everyone that took part! Thanks also to our incredible judges Adam Saltsman, Aleissia Laidacker, David Czarnecki, Matt Hackett, Kyros Starr, and Romana Ramzan. :space_invader::purple_heart:

The GitHub Game Off will return in 2014. :metal::godmode::metal:

Passion Projects with Dana McCallum

Kick off the new year right by joining us on Thursday, January 9th for our first Passion Projects talk of 2014 with Dana McCallum.

dana

Dana is a senior engineer at Twitter, co-founder of Lambda Ladies, and a licensed commercial pilot. She was the lead engineer on Twitter's API for two years, helped create Twitter's advertiser API, and now works on social graph infrastructure. As an advocate for women in engineering and the LGBT community Dana has helped create advocacy teams at Twitter and other companies, and served as a delegate on women's issues in India with the U.S. Department of State. You can find Dana on GitHub and Twitter.

About the event:

  • When? Thursday, January 9th from 6:00-9:00pm
  • Where? GitHub HQ, 88 Colin P. Kelly Junior St., San Francisco, CA
  • Space is limited — you must register to attend this event.
  • Food and beverages will be provided, along with a :notes: live musical performance :notes: by Running In The Fog, before and after the talk.
Something went wrong with that request. Please try again.