My First Contribution to the Git Project
========================================
+:sectanchors:
+[[summary]]
== Summary
This is a tutorial demonstrating the end-to-end workflow of creating a change to
the Git tree, sending it for review, and making changes based on comments.
+[[prerequisites]]
=== Prerequisites
This tutorial assumes you're already fairly familiar with using Git to manage
source code. The Git workflow steps will largely remain unexplained.
+[[related-reading]]
=== Related Reading
This tutorial aims to summarize the following documents, but the reader may find
- `Documentation/SubmittingPatches`
- `Documentation/howto/new-command.txt`
+[[getting-started]]
== Getting Started
+[[cloning]]
=== Clone the Git Repository
Git is mirrored in a number of locations. Clone the repository from one of them;
$ git clone https://github.com/git/git git
----
+[[identify-problem]]
=== Identify Problem to Solve
////
(We've seen some other effort in this space with the implementation of popular
commands such as `sl`.)
+[[setup-workspace]]
=== Set Up Your Workspace
Let's start by making a development branch to work on our changes. Per
We'll make a number of commits here in order to demonstrate how to send a topic
with multiple patches up for review simultaneously.
+[[code-it-up]]
== Code It Up!
NOTE: A reference implementation can be found at
https://github.com/nasamuffin/git/tree/psuh.
+[[add-new-command]]
=== Adding a New Command
Lots of the subcommands are written as builtins, which means they are
sake of brevity. However, fully-fleshed example commit messages are available
on the reference implementation linked at the top of this document.
+[[implementation]]
=== Implementation
It's probably useful to do at least something besides printing out a string.
$ git commit -sm "psuh: display the top of origin/master"
----
+[[add-documentation]]
=== Adding Documentation
Awesome! You've got a fantastic new command that you're ready to share with the
Go ahead and commit your new documentation change.
+[[add-usage]]
=== Adding Usage Text
Try and run `./bin-wrappers/git psuh -h`. Your command should crash at the end.
Go ahead and commit this one, too.
+[[testing]]
== Testing
It's important to test your code - even for a little toy command like this one.
Related reading: `t/README`
+[[overview-test-structure]]
=== Overview of Testing Structure
The tests in Git live in `t/` and are named with a 4-digit decimal number using
the schema shown in the Naming Tests section of `t/README`.
+[[write-new-test]]
=== Writing Your Test
Since this a toy command, let's go ahead and name the test with t9999. However,
by running `make -C t test-lint`, which will check for things like test number
uniqueness, executable bit, and so on.
+[[local-test]]
=== Running Locally
Let's try and run locally:
Go ahead and commit this change, as well.
+[[ready-to-share]]
== Getting Ready to Share
You may have noticed already that the Git project performs its code reviews via
the same; the review process will be covered after the sections on GitGitGadget
and `git send-email`.
+[[howto-ggg]]
== Sending Patches via GitGitGadget
One option for sending patches is to follow a typical pull request workflow and
emails and send them out for you. It also runs the Git continuous integration
suite for you. It's documented at http://gitgitgadget.github.io.
+[[create-fork]]
=== Forking `git/git` on GitHub
Before you can send your patch off to be reviewed using GitGitGadget, you will
Head to the https://github.com/git/git[GitHub mirror] and look for the Fork
button. Place your fork wherever you deem appropriate and create it.
+[[upload-to-fork]]
=== Uploading to Your Own Fork
To upload your branch to your own fork, you'll need to add the new fork as a
Now you should be able to go and check out your newly created branch on GitHub.
+[[send-pr-ggg]]
=== Sending a PR to GitGitGadget
In order to have your code tested and formatted for review, you need to start by
Review the PR's title and description, as it's used by GitGitGadget as the cover
letter for your change. When you're happy, submit your pull request.
+[[run-ci-ggg]]
=== Running CI and Getting Ready to Send
If it's your first time using GitGitGadget (which is likely, as you're using
TODO https://github.com/gitgitgadget/gitgitgadget/issues/83
It'd be nice to be able to verify that the patch looks good before sending it
to everyone on Git mailing list.
+[[check-work-ggg]]
=== Check Your Work
////
+[[send-mail-ggg]]
=== Sending Your Patches
Now that your CI is passing and someone has granted you permission to use
GitGitGadget with the `/allow` command, sending out for review is as simple as
commenting on your PR with `/submit`.
+[[responding-ggg]]
=== Updating With Comments
Skip ahead to <<reviewing,Responding to Reviews>> for information on how to
more with `/submit` - GitGitGadget will automatically add a v2 mark to your
changes.
+[[howto-git-send-email]]
== Sending Patches with `git send-email`
If you don't want to use GitGitGadget, you can also use Git itself to mail your
and being able to send a ``dry run'' mail to yourself to ensure it all looks
good before going out to the list.
+[[setup-git-send-email]]
=== Prerequisite: Setting Up `git send-email`
Configuration for `send-email` can vary based on your operating system and email
configuration can change significantly based on your system and email setup, it
is out of scope for the context of this tutorial.
+[[format-patch]]
=== Preparing Initial Patchset
Sending emails with Git is a two-part process; before you can prepare the emails
Check and make sure that your patches and cover letter template exist in the
directory you specified - you're nearly ready to send out your review!
+[[cover-letter]]
=== Preparing Email
In addition to an email per patch, the Git community also expects your patches
Finally, the letter will include the version of Git used to generate the
patches. You can leave that string alone.
+[[sending-git-send-email]]
=== Sending Email
At this point you should have a directory `psuh/` which is filled with your
Awesome, now the community will drop everything and review your changes. (Just
kidding - be patient!)
+[[v2-git-send-email]]
=== Sending v2
Skip ahead to <<reviewing,Responding to Reviews>> for information on how to
psuh/v2*
----
+[[single-patch]]
=== Bonus Chapter: One-Patch Changes
In some cases, your very small change may consist of only one patch. When that
2.21.0.392.gf8f6787159e-goog
----
+[[now-what]]
== My Patch Got Emailed - Now What?
[[reviewing]]
anyone, that is okay for now! (Later, it may not make sense to do this; take a
look at the section below this one for some context.)
+[[after-approval]]
=== After Review Approval
The Git project has four integration branches: `pu`, `next`, `master`, and