Scott Rifenbark ae06e04cd2 documentation: Created new "Getting Started" manual.
Creation involved removing the overview-manual and replacing it
with the getting-started manual.  All links to the string
"&YOCTO_DOCS_OVERVIEW_URL" had to be replaced with
"&YOCTO_DOCS_GS_URL" across the entire YP manual set.  I renamed
files used to create the manual with prefixes suited for the
new manual name, which is "Getting Started With Yocto Project".

The style sheet for the new manual needed updating to display the
new .PNG image for the title page.  The mega-manual file had to
be updated to include the files.  The mega-manual.sed file had
to be updated to include the new manual and not use the overview
manual.

(From yocto-docs rev: 6c7abf9192390121000f577d6c98f259d290d15d)

Signed-off-by: Scott Rifenbark <srifenbark@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-02-14 15:25:29 +00:00

177 lines
10 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>2.4.2. Basic Commands</title>
<link rel="stylesheet" type="text/css" href="../book.css">
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="Getting Started With Yocto Project">
<link rel="up" href="git.html" title="2.4. Git">
<link rel="prev" href="repositories-tags-and-branches.html" title="2.4.1. Repositories, Tags, and Branches">
<link rel="next" href="yocto-project-repositories.html" title="2.5. Yocto Project Source Repositories">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="section" title="2.4.2. Basic Commands">
<div class="titlepage"><div><div><h3 class="title">
<a name="basic-commands"></a>2.4.2. Basic Commands</h3></div></div></div>
<p>
Git has an extensive set of commands that lets you manage changes
and perform collaboration over the life of a project.
Conveniently though, you can manage with a small set of basic
operations and workflows once you understand the basic
philosophy behind Git.
You do not have to be an expert in Git to be functional.
A good place to look for instruction on a minimal set of Git
commands is
<a class="ulink" href="http://git-scm.com/documentation" target="_self">here</a>.
</p>
<p>
If you do not know much about Git, you should educate
yourself by visiting the links previously mentioned.
</p>
<p>
The following list of Git commands briefly describes some basic
Git operations as a way to get started.
As with any set of commands, this list (in most cases) simply shows
the base command and omits the many arguments they support.
See the Git documentation for complete descriptions and strategies
on how to use these commands:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
<span class="emphasis"><em><code class="filename">git init</code>:</em></span>
Initializes an empty Git repository.
You cannot use Git commands unless you have a
<code class="filename">.git</code> repository.
</p></li>
<li class="listitem"><p><a name="git-commands-clone"></a>
<span class="emphasis"><em><code class="filename">git clone</code>:</em></span>
Creates a local clone of a Git repository that is on
equal footing with a fellow developer&#8217;s Git repository
or an upstream repository.
</p></li>
<li class="listitem"><p>
<span class="emphasis"><em><code class="filename">git add</code>:</em></span>
Locally stages updated file contents to the index that
Git uses to track changes.
You must stage all files that have changed before you
can commit them.
</p></li>
<li class="listitem"><p>
<span class="emphasis"><em><code class="filename">git commit</code>:</em></span>
Creates a local "commit" that documents the changes you
made.
Only changes that have been staged can be committed.
Commits are used for historical purposes, for determining
if a maintainer of a project will allow the change,
and for ultimately pushing the change from your local
Git repository into the project&#8217;s upstream repository.
</p></li>
<li class="listitem"><p>
<span class="emphasis"><em><code class="filename">git status</code>:</em></span>
Reports any modified files that possibly need to be
staged and gives you a status of where you stand regarding
local commits as compared to the upstream repository.
</p></li>
<li class="listitem"><p>
<span class="emphasis"><em><code class="filename">git checkout</code> <em class="replaceable"><code>branch-name</code></em>:</em></span>
Changes your working branch.
This command is analogous to "cd".
</p></li>
<li class="listitem"><p><span class="emphasis"><em><code class="filename">git checkout &#8211;b</code> <em class="replaceable"><code>working-branch</code></em>:</em></span>
Creates and checks out a working branch on your local
machine that you can use to isolate your work.
It is a good idea to use local branches when adding
specific features or changes.
Using isolated branches facilitates easy removal of
changes if they do not work out.
</p></li>
<li class="listitem"><p><span class="emphasis"><em><code class="filename">git branch</code>:</em></span>
Displays the existing local branches associated with your
local repository.
The branch that you have currently checked out is noted
with an asterisk character.
</p></li>
<li class="listitem"><p>
<span class="emphasis"><em><code class="filename">git branch -D</code> <em class="replaceable"><code>branch-name</code></em>:</em></span>
Deletes an existing local branch.
You need to be in a local branch other than the one you
are deleting in order to delete
<em class="replaceable"><code>branch-name</code></em>.
</p></li>
<li class="listitem"><p>
<span class="emphasis"><em><code class="filename">git pull</code>:</em></span>
Retrieves information from an upstream Git repository
and places it in your local Git repository.
You use this command to make sure you are synchronized with
the repository from which you are basing changes
(.e.g. the "master" branch).
</p></li>
<li class="listitem"><p>
<span class="emphasis"><em><code class="filename">git push</code>:</em></span>
Sends all your committed local changes to the upstream Git
repository that your local repository is tracking
(e.g. a contribution repository).
The maintainer of the project draws from these repositories
to merge changes (commits) into the appropriate branch
of project's upstream repository.
</p></li>
<li class="listitem"><p>
<span class="emphasis"><em><code class="filename">git merge</code>:</em></span>
Combines or adds changes from one
local branch of your repository with another branch.
When you create a local Git repository, the default branch
is named "master".
A typical workflow is to create a temporary branch that is
based off "master" that you would use for isolated work.
You would make your changes in that isolated branch,
stage and commit them locally, switch to the "master"
branch, and then use the <code class="filename">git merge</code>
command to apply the changes from your isolated branch
into the currently checked out branch (e.g. "master").
After the merge is complete and if you are done with
working in that isolated branch, you can safely delete
the isolated branch.
</p></li>
<li class="listitem"><p>
<span class="emphasis"><em><code class="filename">git cherry-pick</code>:</em></span>
Choose and apply specific commits from one branch
into another branch.
There are times when you might not be able to merge
all the changes in one branch with
another but need to pick out certain ones.
</p></li>
<li class="listitem">
<p>
<span class="emphasis"><em><code class="filename">gitk</code>:</em></span>
Provides a GUI view of the branches and changes in your
local Git repository.
This command is a good way to graphically see where things
have diverged in your local repository.
</p>
<div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
You need to install the <code class="filename">gitk</code>
package on your development system to use this
command.
</div>
<p>
</p>
</li>
<li class="listitem"><p>
<span class="emphasis"><em><code class="filename">git log</code>:</em></span>
Reports a history of your commits to the repository.
This report lists all commits regardless of whether you
have pushed them upstream or not.
</p></li>
<li class="listitem"><p>
<span class="emphasis"><em><code class="filename">git diff</code>:</em></span>
Displays line-by-line differences between a local
working file and the same file as understood by Git.
This command is useful to see what you have changed
in any given file.
</p></li>
</ul></div>
<p>
</p>
</div></body>
</html>