github.com/sanprasirt/go@v0.0.0-20170607001320-a027466e4b6d/doc/contribute.html (about)

     1  <!--{
     2  	"Title": "Contribution Guide"
     3  }-->
     4  
     5  <p>
     6  The Go project welcomes all contributors. The process of contributing
     7  to the Go project may be different than many projects you are used to.
     8  This document is intended as a guide to help you through the contribution
     9  process. This guide assumes you have a basic understanding of Git and Go.
    10  </p>
    11  
    12  <p>
    13  (Note that the <code>gccgo</code> frontend lives elsewhere;
    14  see <a href="gccgo_contribute.html">Contributing to gccgo</a>.)
    15  </p>
    16  
    17  <p>
    18  Sensitive security-related issues should be reported to <a href="mailto:security@golang.org">security@golang.org</a>.
    19  </p>
    20  
    21  <h1 id="contributor">Becoming a contributor</h1>
    22  
    23  <p>
    24  Before you can contribute to the Go project you need to setup a few prerequisites.
    25  The Go project uses <a href="https://www.gerritcodereview.com/">Gerrit</a>, an open
    26  source online tool, to perform all code reviews.
    27  Gerrit uses your email address as a unique identifier.
    28  The Go project contributing flow is currently configured to work only with Google Accounts.
    29  You must go through the following process <em>prior to contributing</em>.
    30  You only need to do this once per Google Account.
    31  </p>
    32  
    33  <h2 id="auth">Configure Git to use Gerrit</h2>
    34  <p>
    35  You'll need a web browser and a command line terminal.
    36  You should already have Git installed.
    37  </p>
    38  
    39  <p>
    40  Gerrit uses Google Accounts for authentication.
    41  If you don't have a Google Account, you can create an account which
    42  <a href="https://www.google.com/accounts/NewAccount">includes
    43  a new Gmail email account</a> or create an account associated
    44  <a href="https://accounts.google.com/SignUpWithoutGmail">with your existing
    45  email address</a>.
    46  </p>
    47  
    48  <h3>Step 1: Sign in to googlesource and generate a password</h3>
    49  
    50  <p>
    51  Visit <a href="https://go.googlesource.com">go.googlesource.com</a>
    52  and click on "Generate Password" in the page's top right menu bar.
    53  You will be redirected to accounts.google.com to sign in.
    54  </p>
    55  
    56  <h3>Step 2: Run the provided script</h3>
    57  <p>
    58  After signing in, you are taken to a page on go.googlesource.com with the title "Configure Git".
    59  This page contains a personalized script which when run locally will configure git
    60  to have your unique authentication key.
    61  This key is paired with one generated server side similar to how ssh keys work.
    62  </p>
    63  
    64  <p>
    65  Copy and run this script locally in your command line terminal.
    66  (On a Windows computer using cmd you should instead follow the instructions
    67  in the yellow box to run the command. If you are using git-bash use the same
    68  script as *nix.)
    69  </p>
    70  
    71  <p>
    72  Your secret authentication token is now in a <code>.gitcookie</code> file
    73  and Git is configured to use this file.
    74  </p>
    75  
    76  <h3 id="gerrit">Step 3: Register with Gerrit</h3>
    77  
    78  <p>
    79  Now that you have your authentication token, you need to register your
    80  account with Gerrit.
    81  To do this, visit <a href="https://go-review.googlesource.com/login/">
    82  go-review.googlesource.com/login/</a>.
    83  Sign in using the same Google Account you used above.
    84  </p>
    85  
    86  <h2 id="cla">Contributor License Agreement</h2>
    87  
    88  <h3 id="which_cla">Which CLA</h3>
    89  <p>
    90  Before sending your first change to the Go project
    91  you must have completed one of the following two CLAs.
    92  Which CLA you should sign depends on who owns the copyright to your work.
    93  </p>
    94  
    95  <ul>
    96  <li>
    97  If you are the copyright holder, you will need to agree to the
    98  <a href="https://developers.google.com/open-source/cla/individual">individual
    99  contributor license agreement</a>, which can be completed online.
   100  </li>
   101  <li>
   102  If your organization is the copyright holder, the organization
   103  will need to agree to the
   104  <a href="https://developers.google.com/open-source/cla/corporate">corporate
   105  contributor license agreement</a>.<br>
   106  </li>
   107  </ul>
   108  
   109  <p>
   110  <i>If the copyright holder for your contribution has already completed the
   111  agreement in connection with another Google open source project,
   112  it does not need to be completed again.</i>
   113  </p>
   114  
   115  <h3 id="signing_cla">Completing the CLA</h3>
   116  
   117  <p>
   118  You can see your currently signed agreements and sign new ones through the Gerrit
   119  interface.
   120  To do this, <a href="https://go-review.googlesource.com/login/">Log into Gerrit</a>,
   121  then visit the <a href="https://go-review.googlesource.com/settings/agreements">Agreements</a>
   122  page.
   123  If you do not have a signed agreement listed there, you can create one
   124  by clicking "New Contributor Agreement" and following the steps.
   125  </p>
   126  
   127  <p>
   128  If the copyright holder for the code you are submitting changes &mdash; for example,
   129  if you start contributing code on behalf of a new company &mdash; please send email
   130  to golang-dev and let us know, so that we can make sure an appropriate agreement is
   131  completed and update the <code>AUTHORS</code> file.
   132  </p>
   133  
   134  <span id="Code_review"></span>
   135  <h1 id="prepare_dev_env">Preparing a Development Environment for Contributing</h1>
   136  
   137  <h2 id="git-codereview">Setting up Git for submission to Gerrit</h2>
   138  <p>
   139  Changes to Go must be reviewed before they are accepted, no matter who makes the change.
   140  A custom git command called <code>git-codereview</code>, discussed below,
   141  helps manage the code review process through a Google-hosted
   142  <a href="https://go-review.googlesource.com/">instance</a> Gerrit.
   143  </p>
   144  
   145  <h3 id="git-codereview_install">Install the git-codereview command</h3>
   146  <p>
   147  Install the <code>git-codereview</code> command by running,
   148  </p>
   149  
   150  <pre>
   151  $ go get -u golang.org/x/review/git-codereview
   152  </pre>
   153  
   154  <p>
   155  Make sure <code>git-codereview</code> is installed in your shell path, so that the
   156  <code>git</code> command can find it. Check that
   157  </p>
   158  
   159  <pre>
   160  $ git codereview help
   161  </pre>
   162  
   163  <p>
   164  prints help text, not an error.
   165  </p>
   166  
   167  <p>
   168  On Windows, when using git-bash you must make sure that
   169  <code>git-codereview.exe</code> is in your git exec-path.
   170  Run <code>git --exec-path</code> to discover the right location then create a
   171  symbolic link or simply copy the executible from $GOPATH/bin to this directory.
   172  </p>
   173  
   174  <p>
   175  <b>Note to Git aficionados:</b>
   176  The <code>git-codereview</code> command is not required to
   177  upload and manage Gerrit code reviews.
   178  For those who prefer plain Git, the text below gives the Git equivalent of
   179  each git-codereview command.
   180  </p>
   181  
   182  <p>
   183  If you do use plain Git, note that you still need the commit hooks that the
   184  git-codereview command configures; those hooks add a Gerrit
   185  <code>Change-Id</code> line to the commit message and check that all Go source
   186  files have been formatted with gofmt.
   187  Even if you intend to use plain Git for
   188  daily work, install the hooks in a new Git checkout by running
   189  <code>git-codereview</code> <code>hooks</code>.
   190  </p>
   191  
   192  <p>
   193  The workflow described below assumes a single change per branch.
   194  It is also possible to prepare a sequence of (usually related) changes in a single branch.
   195  See the <a href="https://golang.org/x/review/git-codereview">git-codereview documentation</a> for details.
   196  </p>
   197  
   198  <h3 id="git-config">Set up git aliases</h3>
   199  
   200  <p>
   201  The <code>git-codereview</code> command can be run directly from the shell
   202  by typing, for instance,
   203  </p>
   204  
   205  <pre>
   206  $ git codereview sync
   207  </pre>
   208  
   209  <p>
   210  but it is more convenient to set up aliases for <code>git-codereview</code>'s own
   211  subcommands, so that the above becomes,
   212  </p>
   213  
   214  <pre>
   215  $ git sync
   216  </pre>
   217  
   218  <p>
   219  The <code>git-codereview</code> subcommands have been chosen to be distinct from
   220  Git's own, so it's safe to do so.
   221  </p>
   222  
   223  <p>
   224  The aliases are optional, but in the rest of this document we will assume
   225  they are installed.
   226  To install them, copy this text into your Git configuration file
   227  (usually <code>.gitconfig</code> in your home directory):
   228  </p>
   229  
   230  <pre>
   231  [alias]
   232  	change = codereview change
   233  	gofmt = codereview gofmt
   234  	mail = codereview mail
   235  	pending = codereview pending
   236  	submit = codereview submit
   237  	sync = codereview sync
   238  </pre>
   239  
   240  <span id="help"></span>
   241  <h3 id="understanding_git-codereview">Understanding the git-codereview command</h3>
   242  
   243  <p>After installing the <code>git-codereview</code> command, you can run</p>
   244  
   245  <pre>
   246  $ git codereview help
   247  </pre>
   248  
   249  <p>
   250  to learn more about its commands.
   251  You can also read the <a href="https://godoc.org/golang.org/x/review/git-codereview">command documentation</a>.
   252  </p>
   253  
   254  
   255  <h1 id="making_a_contribution">Making a Contribution</h1>
   256  
   257  <h2 id="Design">Discuss your design</h2>
   258  
   259  <p>
   260  The project welcomes submissions but please let everyone know what
   261  you're working on if you want to change or add to the Go repositories.
   262  </p>
   263  
   264  <p>
   265  Before undertaking to write something new for the Go project,
   266  please <a href="https://golang.org/issue/new">file an issue</a>
   267  (or claim an <a href="https://golang.org/issues">existing issue</a>).
   268  Significant changes must go through the
   269  <a href="https://golang.org/s/proposal-process">change proposal process</a>
   270  before they can be accepted.
   271  </p>
   272  
   273  <p>
   274  This process gives everyone a chance to validate the design,
   275  helps prevent duplication of effort,
   276  and ensures that the idea fits inside the goals for the language and tools.
   277  It also checks that the design is sound before code is written;
   278  the code review tool is not the place for high-level discussions.
   279  </p>
   280  
   281  <p>
   282  When planning work, please note that the Go project follows a <a
   283  href="https://golang.org/wiki/Go-Release-Cycle">six-month development cycle</a>.
   284  The latter half of each cycle is a three-month feature freeze during
   285  which only bug fixes and doc updates are accepted. New contributions can be
   286  sent during a feature freeze but will not be accepted until the freeze thaws.
   287  </p>
   288  
   289  <h2 id="making_a_change">Making a change</h2>
   290  
   291  <h3 id="checkout_go">Getting Go Source</h3>
   292  <p>
   293  First you need to have a local copy of the source checked out from the correct
   294  repository.
   295  As Go builds Go you will also likely need to have a working version
   296  of Go installed (some documentation changes may not need this).
   297  This should be a recent version of Go and can be obtained via any package or
   298  binary distribution or you can build it from source.
   299  </p>
   300  
   301  <p>
   302  You should checkout the Go source repo anywhere you want as long as it's
   303  outside of your $GOPATH.
   304  Go to a directory where you want the source to appear and run the following
   305  command in a terminal.
   306  </p>
   307  
   308  <pre>
   309  $ git clone https://go.googlesource.com/go
   310  $ cd go
   311  </pre>
   312  
   313  <h3 id="master">Contributing to the main Go tree</h3>
   314  
   315  <p>
   316  Most Go installations use a release branch, but new changes should
   317  only be made based on the master branch. <br>
   318  (They may be applied later to a release branch as part of the release process,
   319  but most contributors won't do this themselves.)
   320  Before making a change, make sure you start on the master branch:
   321  </p>
   322  
   323  <pre>
   324  $ git checkout master
   325  $ git sync
   326  </pre>
   327  
   328  <p>
   329  (In Git terms, <code>git</code> <code>sync</code> runs
   330  <code>git</code> <code>pull</code> <code>-r</code>.)
   331  </p>
   332  
   333  <h3 id="subrepos">Contributing to subrepositories (golang.org/x/...)</h3>
   334  
   335  <p>
   336  If you are contributing a change to a subrepository, obtain the
   337  Go package using <code>go get</code>. For example, to contribute
   338  to <code>golang.org/x/oauth2</code>, check out the code by running:
   339  </p>
   340  
   341  <pre>
   342  $ go get -d golang.org/x/oauth2/...
   343  </pre>
   344  
   345  <p>
   346  Then, change your directory to the package's source directory
   347  (<code>$GOPATH/src/golang.org/x/oauth2</code>).
   348  </p>
   349  
   350  <h3 id="change">Make your changes</h3>
   351  
   352  <p>
   353  The entire checked-out tree is editable.
   354  Make your changes as you see fit ensuring that you create appropriate
   355  tests along with your changes. Test your changes as you go.
   356  </p>
   357  
   358  <h3 id="copyright">Copyright</h3>
   359  
   360  <p>
   361  Files in the Go repository don't list author names, both to avoid clutter
   362  and to avoid having to keep the lists up to date.
   363  Instead, your name will appear in the
   364  <a href="https://golang.org/change">change log</a> and in the <a
   365  href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file and perhaps the <a
   366  href="/AUTHORS"><code>AUTHORS</code></a> file.
   367  These files are automatically generated from the commit logs perodically.
   368  The <a href="/AUTHORS"><code>AUTHORS</code></a> file defines who &ldquo;The Go
   369  Authors&rdquo;&mdash;the copyright holders&mdash;are.
   370  </p>
   371  
   372  <p>New files that you contribute should use the standard copyright header:</p>
   373  
   374  <pre>
   375  // Copyright 2017 The Go Authors. All rights reserved.
   376  // Use of this source code is governed by a BSD-style
   377  // license that can be found in the LICENSE file.
   378  </pre>
   379  
   380  <p>
   381  Files in the repository are copyright the year they are added.
   382  Do not update the copyright year on files that you change.
   383  </p>
   384  
   385  <h3 id="commit_changes">Commit your changes</h3>
   386  
   387  <p>
   388  Once you have edited files, you must tell Git that they have been modified.
   389  You must also tell Git about any files that are added, removed, or renamed files.
   390  These operations are done with the usual Git commands,
   391  <code>git</code> <code>add</code>,
   392  <code>git</code> <code>rm</code>,
   393  and
   394  <code>git</code> <code>mv</code>.
   395  </p>
   396  
   397  <p>
   398  Once you have the changes queued up, you will want to commit them.
   399  In the Go contribution workflow this is done with a <code>git</code>
   400  <code>change</code> command, which creates a local branch and commits the changes
   401  directly to that local branch.
   402  </p>
   403  
   404  <pre>
   405  $ git change <i>&lt;branch&gt;</i>
   406  </pre>
   407  
   408  <p>
   409  The name <i>&lt;branch&gt;</i> is an arbitrary one you choose to identify the
   410  local branch containing your changes and will not be used elsewhere.
   411  This is an offline operation and nothing will be sent to the server yet.
   412  </p>
   413  
   414  <p>
   415  (In Git terms, <code>git</code> <code>change</code> <code>&lt;branch&gt;</code>
   416  runs <code>git</code> <code>checkout</code> <code>-b</code> <code>branch</code>,
   417  then <code>git</code> <code>branch</code> <code>--set-upstream-to</code> <code>origin/master</code>,
   418  then <code>git</code> <code>commit</code>.)
   419  </p>
   420  
   421  <p>
   422  As the <code>git</code> <code>commit</code> is the final step, Git will open an
   423  editor to ask for a commit message. (It uses the editor named by
   424  the <code>$EDITOR</code> environment variable,
   425  <code>vi</code> by default.)
   426  
   427  The file will look like:
   428  </p>
   429  
   430  <pre>
   431  
   432  # Please enter the commit message for your changes. Lines starting
   433  # with '#' will be ignored, and an empty message aborts the commit.
   434  # On branch foo
   435  # Changes not staged for commit:
   436  #	modified:   editedfile.go
   437  #
   438  </pre>
   439  
   440  <p>
   441  At the beginning of this file is a blank line; replace it
   442  with a thorough description of your change.
   443  The first line of the change description is conventionally a one-line
   444  summary of the change, prefixed by the primary affected package,
   445  and is used as the subject for code review email.
   446  It should complete the sentence "This change modifies Go to _____."
   447  The rest of the description elaborates and should provide context for the
   448  change and explain what it does.
   449  Write in complete sentences with correct punctuation, just like
   450  for your comments in Go.
   451  If there is a helpful reference, mention it here.
   452  If you've fixed an issue, reference it by number with a # before it.
   453  </p>
   454  
   455  <p>
   456  After editing, the template might now read:
   457  </p>
   458  
   459  <pre>
   460  math: improve Sin, Cos and Tan precision for very large arguments
   461  
   462  The existing implementation has poor numerical properties for
   463  large arguments, so use the McGillicutty algorithm to improve
   464  accuracy above 1e10.
   465  
   466  The algorithm is described at http://wikipedia.org/wiki/McGillicutty_Algorithm
   467  
   468  Fixes #159
   469  
   470  # Please enter the commit message for your changes. Lines starting
   471  # with '#' will be ignored, and an empty message aborts the commit.
   472  # On branch foo
   473  # Changes not staged for commit:
   474  #	modified:   editedfile.go
   475  #
   476  </pre>
   477  
   478  <p>
   479  The commented section of the file lists all the modified files in your client.
   480  It is best to keep unrelated changes in different change lists,
   481  so if you see a file listed that should not be included, abort
   482  the command and move that file to a different branch.
   483  </p>
   484  
   485  <p>
   486  The special notation "Fixes #159" associates the change with issue 159 in the
   487  <a href="https://golang.org/issue/159">Go issue tracker</a>.
   488  When this change is eventually applied, the issue
   489  tracker will automatically mark the issue as fixed.
   490  (There are several such conventions, described in detail in the
   491  <a href="https://help.github.com/articles/closing-issues-via-commit-messages/">GitHub Issue Tracker documentation</a>.)
   492  </p>
   493  
   494  <p>
   495  Once you have finished writing the commit message,
   496  save the file and exit the editor.
   497  </p>
   498  
   499  <p>
   500  You must have the $EDITOR environment variable set properly and working properly (exiting cleanly)
   501  for this operation to succeed.
   502  If you run into any issues at this step, it's likely your editor isn't exiting cleanly.
   503  Try setting a different editor in your $EDITOR environment variable.
   504  </p>
   505  
   506  <p>
   507  If you wish to do more editing, re-stage your changes using
   508  <code>git</code> <code>add</code>, and then run
   509  </p>
   510  
   511  <pre>
   512  $ git change
   513  </pre>
   514  
   515  <p>
   516  to update the change description and incorporate the staged changes.
   517  The change description contains a <code>Change-Id</code> line near the bottom,
   518  added by a Git commit hook during the initial
   519  <code>git</code> <code>change</code>.
   520  That line is used by Gerrit to match successive uploads of the same change.
   521  Do not edit or delete it.
   522  </p>
   523  
   524  <p>
   525  (In Git terms, <code>git</code> <code>change</code> with no branch name
   526  runs <code>git</code> <code>commit</code> <code>--amend</code>.)
   527  </p>
   528  
   529  <h3 id="Testing">Testing</h3>
   530  
   531  <p>
   532  You've <a href="code.html">written and tested your code</a>, but
   533  before sending code out for review, run all the tests for the whole
   534  tree to make sure the changes don't break other packages or programs:
   535  </p>
   536  
   537  <pre>
   538  $ cd go/src
   539  $ ./all.bash
   540  </pre>
   541  
   542  <p>
   543  (To build under Windows use <code>all.bat</code>.)
   544  </p>
   545  
   546  <p>
   547  After running for a while, the command should print
   548  </p>
   549  
   550  <pre>
   551  "ALL TESTS PASSED".
   552  </pre>
   553  
   554  <h3 id="mail">Send the change for review</h3>
   555  
   556  <p>
   557  Once the change is ready, send it for review.
   558  This is similar to a <code>git push</code> in a GitHub style workflow.
   559  This is done via the mail alias setup earlier which despite its name, doesn't
   560  directly mail anything, it simply sends the change to Gerrit via git push.
   561  </p>
   562  
   563  <pre>
   564  $ git mail
   565  </pre>
   566  
   567  <p>
   568  (In Git terms, <code>git</code> <code>mail</code> pushes the local committed
   569  changes to Gerrit using <code>git</code> <code>push</code> <code>origin</code>
   570  <code>HEAD:refs/for/master</code>.)
   571  </p>
   572  
   573  <p>
   574  If your change relates to an open issue, please add a comment to the issue
   575  announcing your proposed fix, including a link to your change.
   576  </p>
   577  
   578  <p>
   579  The code review server assigns your change an issue number and URL,
   580  which <code>git</code> <code>mail</code> will print, something like:
   581  </p>
   582  
   583  <pre>
   584  remote: New Changes:
   585  remote:   https://go-review.googlesource.com/99999 math: improved Sin, Cos and Tan precision for very large arguments
   586  </pre>
   587  
   588  <h3>Troubleshooting</h3>
   589  
   590  <p>
   591  The most common way that the <code>git mail</code> command fails is because the
   592  email address used has not gone through the setup above.
   593  <br>
   594  If you see something like...
   595  </p>
   596  
   597  <pre>
   598  remote: Processing changes: refs: 1, done
   599  remote:
   600  remote: ERROR:  In commit ab13517fa29487dcf8b0d48916c51639426c5ee9
   601  remote: ERROR:  author email address XXXXXXXXXXXXXXXXXXX
   602  remote: ERROR:  does not match your user account.
   603  </pre>
   604  
   605  <p>
   606  You need to either add the email address listed to the CLA or set this repo to use
   607  another email address already approved.
   608  </p>
   609  
   610  <p>
   611  First let's change the email address for this repo so this doesn't happen again.
   612  You can change your email address for this repo with the following command:
   613  </p>
   614  
   615  <pre>
   616  $ git config user.email email@address.com
   617  </pre>
   618  
   619  <p>
   620  Then change the previous commit to use this alternative email address.
   621  You can do that with:
   622  </p>
   623  
   624  <pre>
   625  $ git commit --amend --author="Author Name &lt;email@address.com&gt;"
   626  </pre>
   627  
   628  <p>
   629  Finally try to resend with:
   630  </p>
   631  
   632  <pre>
   633  $ git mail
   634  </pre>
   635  
   636  <h3 id="cc">Specifying a reviewer / CCing others</h3>
   637  
   638  <p>
   639  Unless explicitly told otherwise, such as in the discussion leading
   640  up to sending in the change list, it's better not to specify a reviewer.
   641  All changes are automatically CC'ed to the
   642  <a href="https://groups.google.com/group/golang-codereviews">golang-codereviews@googlegroups.com</a>
   643  mailing list. If this is your first ever change, there may be a moderation
   644  delay before it appears on the mailing list, to prevent spam.
   645  </p>
   646  
   647  <p>
   648  You can specify a reviewer or CC interested parties
   649  using the <code>-r</code> or <code>-cc</code> options.
   650  Both accept a comma-separated list of email addresses:
   651  </p>
   652  
   653  <pre>
   654  $ git mail -r joe@golang.org -cc mabel@example.com,math-nuts@swtch.com
   655  </pre>
   656  
   657  <h2 id="review">Going through the review process</h2>
   658  
   659  <p>
   660  Running <code>git</code> <code>mail</code> will send an email to you and the
   661  reviewers asking them to visit the issue's URL and make comments on the change.
   662  When done, the reviewer adds comments through the Gerrit user interface
   663  and clicks "Reply" to send comments back.
   664  You will receive a mail notification when this happens.
   665  You must reply through the web interface.
   666  (Unlike with the old Rietveld review system, replying by mail has no effect.)
   667  </p>
   668  
   669  <h3 id="revise">Revise and resend</h3>
   670  
   671  <p>
   672  The Go contribution workflow is optimized for iterative revisions based on
   673  feedback.
   674  It is rare that an initial contribution will be ready to be applied as is.
   675  As you revise your contribution and resend Gerrit will retain a history of
   676  all the changes and comments made in the single URL.
   677  </p>
   678  
   679  <p>
   680  You must respond to review comments through the web interface.
   681  (Unlike with the old Rietveld review system, responding by mail has no effect.)
   682  </p>
   683  
   684  <p>
   685  When you have revised the code and are ready for another round of review,
   686  stage those changes and use <code>git</code> <code>change</code> to update the
   687  commit.
   688  To send the update change list for another round of review,
   689  run <code>git</code> <code>mail</code> again.
   690  </p>
   691  
   692  <p>
   693  The reviewer can comment on the new copy, and the process repeats.
   694  The reviewer approves the change by giving it a positive score
   695  (+1 or +2) and replying <code>LGTM</code>: looks good to me.
   696  </p>
   697  
   698  <p>
   699  You can see a list of your pending changes by running <code>git</code>
   700  <code>pending</code>, and switch between change branches with <code>git</code>
   701  <code>change</code> <code><i>&lt;branch&gt;</i></code>.
   702  </p>
   703  
   704  <h3 id="sync">Synchronize your client</h3>
   705  
   706  <p>
   707  While you were working, others might have submitted changes to the repository.
   708  To update your local branch, run
   709  </p>
   710  
   711  <pre>
   712  $ git sync
   713  </pre>
   714  
   715  <p>
   716  (In git terms, <code>git</code> <code>sync</code> runs
   717  <code>git</code> <code>pull</code> <code>-r</code>.)
   718  </p>
   719  
   720  <h3 id="resolving_conflicts">Resolving Conflicts</h3>
   721  
   722  <p>
   723  If files you were editing have changed, Git does its best to merge the
   724  remote changes into your local changes.
   725  It may leave some files to merge by hand.
   726  </p>
   727  
   728  <p>
   729  For example, suppose you have edited <code>sin.go</code> but
   730  someone else has committed an independent change.
   731  When you run <code>git</code> <code>sync</code>,
   732  you will get the (scary-looking) output:
   733  
   734  <pre>
   735  $ git sync
   736  Failed to merge in the changes.
   737  Patch failed at 0023 math: improved Sin, Cos and Tan precision for very large arguments
   738  The copy of the patch that failed is found in:
   739     /home/you/repo/.git/rebase-apply/patch
   740  
   741  When you have resolved this problem, run "git rebase --continue".
   742  If you prefer to skip this patch, run "git rebase --skip" instead.
   743  To check out the original branch and stop rebasing, run "git rebase --abort".
   744  </pre>
   745  
   746  <p>
   747  If this happens, run
   748  </p>
   749  
   750  <pre>
   751  $ git status
   752  </pre>
   753  
   754  <p>
   755  to see which files failed to merge.
   756  The output will look something like this:
   757  </p>
   758  
   759  <pre>
   760  rebase in progress; onto a24c3eb
   761  You are currently rebasing branch 'mcgillicutty' on 'a24c3eb'.
   762    (fix conflicts and then run "git rebase --continue")
   763    (use "git rebase --skip" to skip this patch)
   764    (use "git rebase --abort" to check out the original branch)
   765  
   766  Unmerged paths:
   767    (use "git reset HEAD &lt;file&gt;..." to unstage)
   768    (use "git add &lt;file&gt;..." to mark resolution)
   769  
   770  	<i>both modified: sin.go</i>
   771  </pre>
   772  
   773  <p>
   774  The only important part in that transcript is the italicized "both modified"
   775  line: Git failed to merge your changes with the conflicting change.
   776  When this happens, Git leaves both sets of edits in the file,
   777  with conflicts marked by <code>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</code> and
   778  <code>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</code>.
   779  It is now your job to edit the file to combine them.
   780  Continuing the example, searching for those strings in <code>sin.go</code>
   781  might turn up:
   782  </p>
   783  
   784  <pre>
   785  	arg = scale(arg)
   786  &lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD
   787  	if arg &lt; 1e9 {
   788  =======
   789  	if arg &lt; 1e10 {
   790  &gt;&gt;&gt;&gt;&gt;&gt;&gt; mcgillicutty
   791  		largeReduce(arg)
   792  </pre>
   793  
   794  <p>
   795  Git doesn't show it, but suppose the original text that both edits
   796  started with was 1e8; you changed it to 1e10 and the other change to 1e9,
   797  so the correct answer might now be 1e10.
   798  First, edit the section to remove the markers and leave the correct code:
   799  </p>
   800  
   801  <pre>
   802  	arg = scale(arg)
   803  	if arg &lt; 1e10 {
   804  		largeReduce(arg)
   805  </pre>
   806  
   807  <p>
   808  Then tell Git that the conflict is resolved by running
   809  </p>
   810  
   811  <pre>
   812  $ git add sin.go
   813  </pre>
   814  
   815  <p>
   816  If you had been editing the file, say for debugging, but do not
   817  care to preserve your changes, you can run
   818  <code>git</code> <code>reset</code> <code>HEAD</code> <code>sin.go</code>
   819  to abandon your changes.
   820  Then run <code>git</code> <code>rebase</code> <code>--continue</code> to
   821  restore the change commit.
   822  </p>
   823  
   824  <h3 id="download">Reviewing code by others</h3>
   825  
   826  <p>
   827  As part of the review process reviewers can propose changes directly (in the
   828  GitHub workflow this would be someone else attaching commits to a pull request).
   829  
   830  You can import these changes proposed by someone else into your local Git repository.
   831  On the Gerrit review page, click the "Download ▼" link in the upper right
   832  corner, copy the "Checkout" command and run it from your local Git repo. It
   833  should look something like this:
   834  </p>
   835  
   836  <pre>
   837  $ git fetch https://go.googlesource.com/review refs/changes/21/1221/1 &amp;&amp; git checkout FETCH_HEAD
   838  </pre>
   839  
   840  <p>
   841  To revert, change back to the branch you were working in.
   842  </p>
   843  
   844  <h2 id="submit">Apply the change to the master branch</h2>
   845  
   846  <p>
   847  After the code has been <code>LGTM</code>'ed, an approver may
   848  apply it to the master branch using the Gerrit UI.
   849  There is a "Submit" button on the web page for the change
   850  that appears once the change is approved (marked +2).
   851  </p>
   852  
   853  <p>
   854  This checks the change into the repository.
   855  The change description will include a link to the code review,
   856  and the code review will be updated with a link to the change
   857  in the repository.
   858  Since the method used to integrate the changes is "Cherry Pick",
   859  the commit hashes in the repository will be changed by
   860  the "Submit" operation.
   861  </p>
   862  
   863  <h2 id="more">More information</h2>
   864  
   865  <p>
   866  In addition to the information here, the Go community maintains a <a
   867  href="https://golang.org/wiki/CodeReview">CodeReview</a> wiki page.
   868  Feel free to contribute to this page as you learn the review process.
   869  </p>