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