diff options
Diffstat (limited to 'documentation/ref-manual/ref-development-environment.xml')
| -rw-r--r-- | documentation/ref-manual/ref-development-environment.xml | 356 |
1 files changed, 355 insertions, 1 deletions
diff --git a/documentation/ref-manual/ref-development-environment.xml b/documentation/ref-manual/ref-development-environment.xml index 08e790b7a2..234800df69 100644 --- a/documentation/ref-manual/ref-development-environment.xml +++ b/documentation/ref-manual/ref-development-environment.xml | |||
| @@ -256,6 +256,360 @@ | |||
| 256 | </para> | 256 | </para> |
| 257 | </section> | 257 | </section> |
| 258 | 258 | ||
| 259 | <section id='git'> | ||
| 260 | <title>Git</title> | ||
| 261 | |||
| 262 | <para> | ||
| 263 | The Yocto Project makes extensive use of Git, which is a | ||
| 264 | free, open source distributed version control system. | ||
| 265 | Git supports distributed development, non-linear development, | ||
| 266 | and can handle large projects. | ||
| 267 | It is best that you have some fundamental understanding | ||
| 268 | of how Git tracks projects and how to work with Git if | ||
| 269 | you are going to use the Yocto Project for development. | ||
| 270 | This section provides a quick overview of how Git works and | ||
| 271 | provides you with a summary of some essential Git commands. | ||
| 272 | </para> | ||
| 273 | |||
| 274 | <para> | ||
| 275 | For more information on Git, see | ||
| 276 | <ulink url='http://git-scm.com/documentation'></ulink>. | ||
| 277 | If you need to download Git, it is recommended that you add Git | ||
| 278 | to your system through your distribution's "software store" | ||
| 279 | (e.g. for Ubuntu, use the Ubuntu Software feature). | ||
| 280 | For the Git download page, see | ||
| 281 | <ulink url='http://git-scm.com/download'></ulink>. | ||
| 282 | </para> | ||
| 283 | |||
| 284 | <section id='repositories-tags-and-branches'> | ||
| 285 | <title>Repositories, Tags, and Branches</title> | ||
| 286 | |||
| 287 | <para> | ||
| 288 | As mentioned briefly in the previous section and also in the | ||
| 289 | "<link linkend='workflows'>Workflows</link>" section, | ||
| 290 | the Yocto Project maintains source repositories at | ||
| 291 | <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>. | ||
| 292 | If you look at this web-interface of the repositories, each item | ||
| 293 | is a separate Git repository. | ||
| 294 | </para> | ||
| 295 | |||
| 296 | <para> | ||
| 297 | Git repositories use branching techniques that track content | ||
| 298 | change (not files) within a project (e.g. a new feature or updated | ||
| 299 | documentation). | ||
| 300 | Creating a tree-like structure based on project divergence allows | ||
| 301 | for excellent historical information over the life of a project. | ||
| 302 | This methodology also allows for an environment from which you can | ||
| 303 | do lots of local experimentation on projects as you develop | ||
| 304 | changes or new features. | ||
| 305 | </para> | ||
| 306 | |||
| 307 | <para> | ||
| 308 | A Git repository represents all development efforts for a given | ||
| 309 | project. | ||
| 310 | For example, the Git repository <filename>poky</filename> contains | ||
| 311 | all changes and developments for Poky over the course of its | ||
| 312 | entire life. | ||
| 313 | That means that all changes that make up all releases are captured. | ||
| 314 | The repository maintains a complete history of changes. | ||
| 315 | </para> | ||
| 316 | |||
| 317 | <para> | ||
| 318 | You can create a local copy of any repository by "cloning" it | ||
| 319 | with the <filename>git clone</filename> command. | ||
| 320 | When you clone a Git repository, you end up with an identical | ||
| 321 | copy of the repository on your development system. | ||
| 322 | Once you have a local copy of a repository, you can take steps to | ||
| 323 | develop locally. | ||
| 324 | For examples on how to clone Git repositories, see the | ||
| 325 | "<ulink url='&YOCTO_DOCS_DEV_URL;#getting-setup'>Getting Set Up</ulink>" | ||
| 326 | section in the Yocto Project Development Manual. | ||
| 327 | </para> | ||
| 328 | |||
| 329 | <para> | ||
| 330 | It is important to understand that Git tracks content change and | ||
| 331 | not files. | ||
| 332 | Git uses "branches" to organize different development efforts. | ||
| 333 | For example, the <filename>poky</filename> repository has | ||
| 334 | several branches that include the current "&DISTRO_NAME_NO_CAP;" | ||
| 335 | branch, the "master" branch, and many branches for past | ||
| 336 | Yocto Project releases. | ||
| 337 | You can see all the branches by going to | ||
| 338 | <ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/'></ulink> and | ||
| 339 | clicking on the | ||
| 340 | <filename><ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/refs/heads'>[...]</ulink></filename> | ||
| 341 | link beneath the "Branch" heading. | ||
| 342 | </para> | ||
| 343 | |||
| 344 | <para> | ||
| 345 | Each of these branches represents a specific area of development. | ||
| 346 | The "master" branch represents the current or most recent | ||
| 347 | development. | ||
| 348 | All other branches represent offshoots of the "master" branch. | ||
| 349 | </para> | ||
| 350 | |||
| 351 | <para> | ||
| 352 | When you create a local copy of a Git repository, the copy has | ||
| 353 | the same set of branches as the original. | ||
| 354 | This means you can use Git to create a local working area | ||
| 355 | (also called a branch) that tracks a specific development branch | ||
| 356 | from the upstream source Git repository. | ||
| 357 | in other words, you can define your local Git environment to | ||
| 358 | work on any development branch in the repository. | ||
| 359 | To help illustrate, consider the following example Git commands: | ||
| 360 | <literallayout class='monospaced'> | ||
| 361 | $ cd ~ | ||
| 362 | $ git clone git://git.yoctoproject.org/poky | ||
| 363 | $ cd poky | ||
| 364 | $ git checkout -b &DISTRO_NAME_NO_CAP; origin/&DISTRO_NAME_NO_CAP; | ||
| 365 | </literallayout> | ||
| 366 | In the previous example after moving to the home directory, the | ||
| 367 | <filename>git clone</filename> command creates a | ||
| 368 | local copy of the upstream <filename>poky</filename> Git repository. | ||
| 369 | By default, Git checks out the "master" branch for your work. | ||
| 370 | After changing the working directory to the new local repository | ||
| 371 | (i.e. <filename>poky</filename>), the | ||
| 372 | <filename>git checkout</filename> command creates | ||
| 373 | and checks out a local branch named "&DISTRO_NAME_NO_CAP;", which | ||
| 374 | tracks the upstream "origin/&DISTRO_NAME_NO_CAP;" branch. | ||
| 375 | Changes you make while in this branch would ultimately affect | ||
| 376 | the upstream "&DISTRO_NAME_NO_CAP;" branch of the | ||
| 377 | <filename>poky</filename> repository. | ||
| 378 | </para> | ||
| 379 | |||
| 380 | <para> | ||
| 381 | It is important to understand that when you create and checkout a | ||
| 382 | local working branch based on a branch name, | ||
| 383 | your local environment matches the "tip" of that particular | ||
| 384 | development branch at the time you created your local branch, | ||
| 385 | which could be different from the files in the "master" branch | ||
| 386 | of the upstream repository. | ||
| 387 | In other words, creating and checking out a local branch based on | ||
| 388 | the "&DISTRO_NAME_NO_CAP;" branch name is not the same as | ||
| 389 | cloning and checking out the "master" branch if the repository. | ||
| 390 | Keep reading to see how you create a local snapshot of a Yocto | ||
| 391 | Project Release. | ||
| 392 | </para> | ||
| 393 | |||
| 394 | <para> | ||
| 395 | Git uses "tags" to mark specific changes in a repository. | ||
| 396 | Typically, a tag is used to mark a special point such as the final | ||
| 397 | change before a project is released. | ||
| 398 | You can see the tags used with the <filename>poky</filename> Git | ||
| 399 | repository by going to | ||
| 400 | <ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/'></ulink> and | ||
| 401 | clicking on the | ||
| 402 | <filename><ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/refs/tags'>[...]</ulink></filename> | ||
| 403 | link beneath the "Tag" heading. | ||
| 404 | </para> | ||
| 405 | |||
| 406 | <para> | ||
| 407 | Some key tags for the <filename>poky</filename> are | ||
| 408 | <filename>jethro-14.0.3</filename>, | ||
| 409 | <filename>morty-16.0.1</filename>, | ||
| 410 | <filename>pyro-17.0.0</filename>, and | ||
| 411 | <filename>&DISTRO_NAME_NO_CAP;-&POKYVERSION;</filename>. | ||
| 412 | These tags represent Yocto Project releases. | ||
| 413 | </para> | ||
| 414 | |||
| 415 | <para> | ||
| 416 | When you create a local copy of the Git repository, you also | ||
| 417 | have access to all the tags in the upstream repository. | ||
| 418 | Similar to branches, you can create and checkout a local working | ||
| 419 | Git branch based on a tag name. | ||
| 420 | When you do this, you get a snapshot of the Git repository that | ||
| 421 | reflects the state of the files when the change was made associated | ||
| 422 | with that tag. | ||
| 423 | The most common use is to checkout a working branch that matches | ||
| 424 | a specific Yocto Project release. | ||
| 425 | Here is an example: | ||
| 426 | <literallayout class='monospaced'> | ||
| 427 | $ cd ~ | ||
| 428 | $ git clone git://git.yoctoproject.org/poky | ||
| 429 | $ cd poky | ||
| 430 | $ git fetch --all --tags --prune | ||
| 431 | $ git checkout tags/pyro-17.0.0 -b my-pyro-17.0.0 | ||
| 432 | </literallayout> | ||
| 433 | In this example, the name of the top-level directory of your | ||
| 434 | local Yocto Project repository is <filename>poky</filename>. | ||
| 435 | After moving to the <filename>poky</filename> directory, the | ||
| 436 | <filename>git fetch</filename> command makes all the upstream | ||
| 437 | tags available locally in your repository. | ||
| 438 | Finally, the <filename>git checkout</filename> command | ||
| 439 | creates and checks out a branch named "my-pyro-17.0.0" that is | ||
| 440 | based on the specific change upstream in the repository | ||
| 441 | associated with the "pyro-17.0.0" tag. | ||
| 442 | The files in your repository now exactly match that particular | ||
| 443 | Yocto Project release as it is tagged in the upstream Git | ||
| 444 | repository. | ||
| 445 | It is important to understand that when you create and | ||
| 446 | checkout a local working branch based on a tag, your environment | ||
| 447 | matches a specific point in time and not the entire development | ||
| 448 | branch (i.e. the "tip" of the branch). | ||
| 449 | </para> | ||
| 450 | </section> | ||
| 451 | |||
| 452 | <section id='basic-commands'> | ||
| 453 | <title>Basic Commands</title> | ||
| 454 | |||
| 455 | <para> | ||
| 456 | Git has an extensive set of commands that lets you manage changes | ||
| 457 | and perform collaboration over the life of a project. | ||
| 458 | Conveniently though, you can manage with a small set of basic | ||
| 459 | operations and workflows once you understand the basic | ||
| 460 | philosophy behind Git. | ||
| 461 | You do not have to be an expert in Git to be functional. | ||
| 462 | A good place to look for instruction on a minimal set of Git | ||
| 463 | commands is | ||
| 464 | <ulink url='http://git-scm.com/documentation'>here</ulink>. | ||
| 465 | </para> | ||
| 466 | |||
| 467 | <para> | ||
| 468 | If you do not know much about Git, you should educate | ||
| 469 | yourself by visiting the links previously mentioned. | ||
| 470 | </para> | ||
| 471 | |||
| 472 | <para> | ||
| 473 | The following list of Git commands briefly describes some basic | ||
| 474 | Git operations as a way to get started. | ||
| 475 | As with any set of commands, this list (in most cases) simply shows | ||
| 476 | the base command and omits the many arguments they support. | ||
| 477 | See the Git documentation for complete descriptions and strategies | ||
| 478 | on how to use these commands: | ||
| 479 | <itemizedlist> | ||
| 480 | <listitem><para> | ||
| 481 | <emphasis><filename>git init</filename>:</emphasis> | ||
| 482 | Initializes an empty Git repository. | ||
| 483 | You cannot use Git commands unless you have a | ||
| 484 | <filename>.git</filename> repository. | ||
| 485 | </para></listitem> | ||
| 486 | <listitem><para> | ||
| 487 | <emphasis><filename>git clone</filename>:</emphasis> | ||
| 488 | Creates a local clone of a Git repository that is on | ||
| 489 | equal footing with a fellow developer’s Git repository | ||
| 490 | or an upstream repository. | ||
| 491 | </para></listitem> | ||
| 492 | <listitem><para> | ||
| 493 | <emphasis><filename>git add</filename>:</emphasis> | ||
| 494 | Locally stages updated file contents to the index that | ||
| 495 | Git uses to track changes. | ||
| 496 | You must stage all files that have changed before you | ||
| 497 | can commit them. | ||
| 498 | </para></listitem> | ||
| 499 | <listitem><para> | ||
| 500 | <emphasis><filename>git commit</filename>:</emphasis> | ||
| 501 | Creates a local "commit" that documents the changes you | ||
| 502 | made. | ||
| 503 | Only changes that have been staged can be committed. | ||
| 504 | Commits are used for historical purposes, for determining | ||
| 505 | if a maintainer of a project will allow the change, | ||
| 506 | and for ultimately pushing the change from your local | ||
| 507 | Git repository into the project’s upstream repository. | ||
| 508 | </para></listitem> | ||
| 509 | <listitem><para> | ||
| 510 | <emphasis><filename>git status</filename>:</emphasis> | ||
| 511 | Reports any modified files that possibly need to be | ||
| 512 | staged and gives you a status of where you stand regarding | ||
| 513 | local commits as compared to the upstream repository. | ||
| 514 | </para></listitem> | ||
| 515 | <listitem><para> | ||
| 516 | <emphasis><filename>git checkout</filename> <replaceable>branch-name</replaceable>:</emphasis> | ||
| 517 | Changes your working branch. | ||
| 518 | This command is analogous to "cd". | ||
| 519 | </para></listitem> | ||
| 520 | <listitem><para><emphasis><filename>git checkout –b</filename> <replaceable>working-branch</replaceable>:</emphasis> | ||
| 521 | Creates and checks out a working branch on your local | ||
| 522 | machine that you can use to isolate your work. | ||
| 523 | It is a good idea to use local branches when adding | ||
| 524 | specific features or changes. | ||
| 525 | Using isolated branches facilitates easy removal of | ||
| 526 | changes if they do not work out. | ||
| 527 | </para></listitem> | ||
| 528 | <listitem><para><emphasis><filename>git branch</filename>:</emphasis> | ||
| 529 | Displays the existing local branches associated with your | ||
| 530 | local repository. | ||
| 531 | The branch that you have currently checked out is noted | ||
| 532 | with an asterisk character. | ||
| 533 | </para></listitem> | ||
| 534 | <listitem><para> | ||
| 535 | <emphasis><filename>git branch -D</filename> <replaceable>branch-name</replaceable>:</emphasis> | ||
| 536 | Deletes an existing local branch. | ||
| 537 | You need to be in a local branch other than the one you | ||
| 538 | are deleting in order to delete | ||
| 539 | <replaceable>branch-name</replaceable>. | ||
| 540 | </para></listitem> | ||
| 541 | <listitem><para> | ||
| 542 | <emphasis><filename>git pull</filename>:</emphasis> | ||
| 543 | Retrieves information from an upstream Git repository | ||
| 544 | and places it in your local Git repository. | ||
| 545 | You use this command to make sure you are synchronized with | ||
| 546 | the repository from which you are basing changes | ||
| 547 | (.e.g. the "master" branch). | ||
| 548 | </para></listitem> | ||
| 549 | <listitem><para> | ||
| 550 | <emphasis><filename>git push</filename>:</emphasis> | ||
| 551 | Sends all your committed local changes to the upstream Git | ||
| 552 | repository that your local repository is tracking | ||
| 553 | (e.g. a contribution repository). | ||
| 554 | The maintainer of the project draws from these repositories | ||
| 555 | to merge changes (commits) into the appropriate branch | ||
| 556 | of project's upstream repository. | ||
| 557 | </para></listitem> | ||
| 558 | <listitem><para> | ||
| 559 | <emphasis><filename>git merge</filename>:</emphasis> | ||
| 560 | Combines or adds changes from one | ||
| 561 | local branch of your repository with another branch. | ||
| 562 | When you create a local Git repository, the default branch | ||
| 563 | is named "master". | ||
| 564 | A typical workflow is to create a temporary branch that is | ||
| 565 | based off "master" that you would use for isolated work. | ||
| 566 | You would make your changes in that isolated branch, | ||
| 567 | stage and commit them locally, switch to the "master" | ||
| 568 | branch, and then use the <filename>git merge</filename> | ||
| 569 | command to apply the changes from your isolated branch | ||
| 570 | into the currently checked out branch (e.g. "master"). | ||
| 571 | After the merge is complete and if you are done with | ||
| 572 | working in that isolated branch, you can safely delete | ||
| 573 | the isolated branch. | ||
| 574 | </para></listitem> | ||
| 575 | <listitem><para> | ||
| 576 | <emphasis><filename>git cherry-pick</filename>:</emphasis> | ||
| 577 | Choose and apply specific commits from one branch | ||
| 578 | into another branch. | ||
| 579 | There are times when you might not be able to merge | ||
| 580 | all the changes in one branch with | ||
| 581 | another but need to pick out certain ones. | ||
| 582 | </para></listitem> | ||
| 583 | <listitem><para> | ||
| 584 | <emphasis><filename>gitk</filename>:</emphasis> | ||
| 585 | Provides a GUI view of the branches and changes in your | ||
| 586 | local Git repository. | ||
| 587 | This command is a good way to graphically see where things | ||
| 588 | have diverged in your local repository. | ||
| 589 | <note> | ||
| 590 | You need to install the <filename>gitk</filename> | ||
| 591 | package on your development system to use this | ||
| 592 | command. | ||
| 593 | </note> | ||
| 594 | </para></listitem> | ||
| 595 | <listitem><para> | ||
| 596 | <emphasis><filename>git log</filename>:</emphasis> | ||
| 597 | Reports a history of your commits to the repository. | ||
| 598 | This report lists all commits regardless of whether you | ||
| 599 | have pushed them upstream or not. | ||
| 600 | </para></listitem> | ||
| 601 | <listitem><para> | ||
| 602 | <emphasis><filename>git diff</filename>:</emphasis> | ||
| 603 | Displays line-by-line differences between a local | ||
| 604 | working file and the same file as understood by Git. | ||
| 605 | This command is useful to see what you have changed | ||
| 606 | in any given file. | ||
| 607 | </para></listitem> | ||
| 608 | </itemizedlist> | ||
| 609 | </para> | ||
| 610 | </section> | ||
| 611 | </section> | ||
| 612 | |||
| 259 | <section id='yocto-project-repositories'> | 613 | <section id='yocto-project-repositories'> |
| 260 | <title>Yocto Project Source Repositories</title> | 614 | <title>Yocto Project Source Repositories</title> |
| 261 | 615 | ||
| @@ -290,7 +644,7 @@ | |||
| 290 | <link linkend='source-directory'>Source Directory</link> | 644 | <link linkend='source-directory'>Source Directory</link> |
| 291 | and the files for supported BSPs | 645 | and the files for supported BSPs |
| 292 | (e.g., <filename>meta-intel</filename>) is to use | 646 | (e.g., <filename>meta-intel</filename>) is to use |
| 293 | <ulink url='&YOCTO_DOCS_DEV_URL;#git'>Git</ulink> to create a local copy of | 647 | <link linkend='git'>Git</link> to create a local copy of |
| 294 | the upstream repositories. | 648 | the upstream repositories. |
| 295 | </para></listitem> | 649 | </para></listitem> |
| 296 | <listitem><para> | 650 | <listitem><para> |
