<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\r
<head>\r
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\r
-<meta name="generator" content="AsciiDoc 7.0.1" />\r
+<meta name="generator" content="AsciiDoc 7.0.2" />\r
<style type="text/css">\r
/* Debug borders */\r
p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {\r
$ git prune\r
$ git count-objects <b>(2)</b>\r
$ git repack <b>(3)</b>\r
-$ git prune <b>(4)</b>\r
-\r
-<b>(1)</b> running without "--full" is usually cheap and assures the\r
+$ git prune <b>(4)</b></tt></pre>\r
+</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+running without "—full" is usually cheap and assures the\r
repository health reasonably well.\r
-<b>(2)</b> check how many loose objects there are and how much\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+check how many loose objects there are and how much\r
diskspace is wasted by not repacking.\r
-<b>(3)</b> without "-a" repacks incrementally. repacking every 4-5MB\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+without "-a" repacks incrementally. repacking every 4-5MB\r
of loose objects accumulation may be a good rule of thumb.\r
-<b>(4)</b> after repack, prune removes the duplicate loose objects.</tt></pre>\r
-</div></div>\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+after repack, prune removes the duplicate loose objects.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
<dt>\r
Repack a small project into single pack.\r
<div class="listingblock">\r
<div class="content">\r
<pre><tt>$ git repack -a -d <b>(1)</b>\r
-$ git prune\r
-\r
-<b>(1)</b> pack all the objects reachable from the refs into one pack\r
-and remove unneeded other packs</tt></pre>\r
+$ git prune</tt></pre>\r
</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+pack all the objects reachable from the refs into one pack\r
+and remove unneeded other packs\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
</dl>\r
</div>\r
$ git-init-db\r
$ git add . <b>(1)</b>\r
$ git commit -m 'import of frotz source tree.'\r
-$ git tag v2.43 <b>(2)</b>\r
-\r
-<b>(1)</b> add everything under the current directory.\r
-<b>(2)</b> make a lightweight, unannotated tag.</tt></pre>\r
+$ git tag v2.43 <b>(2)</b></tt></pre>\r
</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+add everything under the current directory.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+make a lightweight, unannotated tag.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
<dt>\r
Create a topic branch and develop.\r
$ git checkout master <b>(9)</b>\r
$ git pull . alsa-audio <b>(10)</b>\r
$ git log --since='3 days ago' <b>(11)</b>\r
-$ git log v2.43.. curses/ <b>(12)</b>\r
-\r
-<b>(1)</b> create a new topic branch.\r
-<b>(2)</b> revert your botched changes in "curses/ux_audio_oss.c".\r
-<b>(3)</b> you need to tell git if you added a new file; removal and\r
+$ git log v2.43.. curses/ <b>(12)</b></tt></pre>\r
+</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+create a new topic branch.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+revert your botched changes in "curses/ux_audio_oss.c".\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+you need to tell git if you added a new file; removal and\r
modification will be caught if you do "commit -a" later.\r
-<b>(4)</b> to see what changes you are committing.\r
-<b>(5)</b> commit everything as you have tested, with your sign-off.\r
-<b>(6)</b> take the last commit back, keeping what is in the working tree.\r
-<b>(7)</b> look at the changes since the premature commit we took back.\r
-<b>(8)</b> redo the commit undone in the previous step, using the message\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+to see what changes you are committing.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+commit everything as you have tested, with your sign-off.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+take the last commit back, keeping what is in the working tree.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+look at the changes since the premature commit we took back.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+redo the commit undone in the previous step, using the message\r
you originally wrote.\r
-<b>(9)</b> switch to the master branch.\r
-<b>(10)</b> merge a topic branch into your master branch\r
-<b>(11)</b> review commit logs; other forms to limit output can be\r
-combined and include --max-count=10 (show 10 commits), --until='2005-12-10'.\r
-<b>(12)</b> view only the changes that touch what's in curses/\r
-directory, since v2.43 tag.</tt></pre>\r
-</div></div>\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+switch to the master branch.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+merge a topic branch into your master branch\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+review commit logs; other forms to limit output can be\r
+combined and include —max-count=10 (show 10 commits), —until=<em>2005-12-10</em>.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+view only the changes that touch what's in curses/\r
+directory, since v2.43 tag.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
</dl>\r
</div>\r
$ git pull git://git.kernel.org/pub/.../jgarzik/libata-dev.git ALL <b>(5)</b>\r
$ git reset --hard ORIG_HEAD <b>(6)</b>\r
$ git prune <b>(7)</b>\r
-$ git fetch --tags <b>(8)</b>\r
-\r
-<b>(1)</b> repeat as needed.\r
-<b>(2)</b> extract patches from your branch for e-mail submission.\r
-<b>(3)</b> "pull" fetches from "origin" by default and merges into the\r
+$ git fetch --tags <b>(8)</b></tt></pre>\r
+</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+repeat as needed.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+extract patches from your branch for e-mail submission.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+"pull" fetches from "origin" by default and merges into the\r
current branch.\r
-<b>(4)</b> immediately after pulling, look at the changes done upstream\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+immediately after pulling, look at the changes done upstream\r
since last time we checked, only in the\r
area we are interested in.\r
-<b>(5)</b> fetch from a specific branch from a specific repository and merge.\r
-<b>(6)</b> revert the pull.\r
-<b>(7)</b> garbage collect leftover objects from reverted pull.\r
-<b>(8)</b> from time to time, obtain official tags from the "origin"\r
-and store them under .git/refs/tags/.</tt></pre>\r
-</div></div>\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+fetch from a specific branch from a specific repository and merge.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+revert the pull.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+garbage collect leftover objects from reverted pull.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+from time to time, obtain official tags from the "origin"\r
+and store them under .git/refs/tags/.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
<dt>\r
Push into another repository.\r
\r
mothership$ cd frotz\r
mothership$ git checkout master\r
-mothership$ git pull . satellite <b>(5)</b>\r
-\r
-<b>(1)</b> mothership machine has a frotz repository under your home\r
+mothership$ git pull . satellite <b>(5)</b></tt></pre>\r
+</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+mothership machine has a frotz repository under your home\r
directory; clone from it to start a repository on the satellite\r
machine.\r
-<b>(2)</b> clone creates this file by default. It arranges "git pull"\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+clone creates this file by default. It arranges "git pull"\r
to fetch and store the master branch head of mothership machine\r
to local "origin" branch.\r
-<b>(3)</b> arrange "git push" to push local "master" branch to\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+arrange "git push" to push local "master" branch to\r
"satellite" branch of the mothership machine.\r
-<b>(4)</b> push will stash our work away on "satellite" branch on the\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+push will stash our work away on "satellite" branch on the\r
mothership machine. You could use this as a back-up method.\r
-<b>(5)</b> on mothership machine, merge the work done on the satellite\r
-machine into the master branch.</tt></pre>\r
-</div></div>\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+on mothership machine, merge the work done on the satellite\r
+machine into the master branch.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
<dt>\r
Branch off of a specific tag.\r
$ edit/compile/test; git commit -a\r
$ git checkout master\r
$ git format-patch -k -m --stdout v2.6.14..private2.6.14 |\r
- git am -3 -k <b>(2)</b>\r
-\r
-<b>(1)</b> create a private branch based on a well known (but somewhat behind)\r
-tag.\r
-<b>(2)</b> forward port all changes in private2.6.14 branch to master branch\r
-without a formal "merging".</tt></pre>\r
+ git am -3 -k <b>(2)</b></tt></pre>\r
</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+create a private branch based on a well known (but somewhat behind)\r
+tag.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+forward port all changes in private2.6.14 branch to master branch\r
+without a formal "merging".\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
</dl>\r
</div>\r
$ git tag -s -m 'GIT 0.99.9x' v0.99.9x <b>(10)</b>\r
$ git fetch ko && git show-branch master maint 'tags/ko-*' <b>(11)</b>\r
$ git push ko <b>(12)</b>\r
-$ git push ko v0.99.9x <b>(13)</b>\r
-\r
-<b>(1)</b> see what I was in the middle of doing, if any.\r
-<b>(2)</b> see what topic branches I have and think about how ready\r
+$ git push ko v0.99.9x <b>(13)</b></tt></pre>\r
+</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+see what I was in the middle of doing, if any.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+see what topic branches I have and think about how ready\r
they are.\r
-<b>(3)</b> read mails, save ones that are applicable, and save others\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+read mails, save ones that are applicable, and save others\r
that are not quite ready.\r
-<b>(4)</b> apply them, interactively, with my sign-offs.\r
-<b>(5)</b> create topic branch as needed and apply, again with my\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+apply them, interactively, with my sign-offs.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+create topic branch as needed and apply, again with my\r
sign-offs.\r
-<b>(6)</b> rebase internal topic branch that has not been merged to the\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+rebase internal topic branch that has not been merged to the\r
master, nor exposed as a part of a stable branch.\r
-<b>(7)</b> restart "pu" every time from the master.\r
-<b>(8)</b> and bundle topic branches still cooking.\r
-<b>(9)</b> backport a critical fix.\r
-<b>(10)</b> create a signed tag.\r
-<b>(11)</b> make sure I did not accidentally rewind master beyond what I\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+restart "pu" every time from the master.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+and bundle topic branches still cooking.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+backport a critical fix.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+create a signed tag.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+make sure I did not accidentally rewind master beyond what I\r
already pushed out. "ko" shorthand points at the repository I have\r
at kernel.org, and looks like this:\r
$ cat .git/remotes/ko\r
Push: maint\r
In the output from "git show-branch", "master" should have\r
everything "ko-master" has.\r
-<b>(12)</b> push out the bleeding edge.\r
-<b>(13)</b> push the tag out, too.</tt></pre>\r
-</div></div>\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+push out the bleeding edge.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+push the tag out, too.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
</dl>\r
</div>\r
cindy:x:1002:1002::/home/cindy:/usr/bin/git-shell\r
david:x:1003:1003::/home/david:/usr/bin/git-shell\r
$ grep git /etc/shells <b>(2)</b>\r
-/usr/bin/git-shell\r
-\r
-<b>(1)</b> log-in shell is set to /usr/bin/git-shell, which does not\r
+/usr/bin/git-shell</tt></pre>\r
+</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+log-in shell is set to /usr/bin/git-shell, which does not\r
allow anything but "git push" and "git pull". The users should\r
get an ssh access to the machine.\r
-<b>(2)</b> in many distributions /etc/shells needs to list what is used\r
-as the login shell.</tt></pre>\r
-</div></div>\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+in many distributions /etc/shells needs to list what is used\r
+as the login shell.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
<dt>\r
CVS-style shared repository.\r
$ cat info/allowed-users <b>(4)</b>\r
refs/heads/master alice\|cindy\r
refs/heads/doc-update bob\r
-refs/tags/v[0-9]* david\r
-\r
-<b>(1)</b> place the developers into the same git group.\r
-<b>(2)</b> and make the shared repository writable by the group.\r
-<b>(3)</b> use update-hook example by Carl from Documentation/howto/\r
+refs/tags/v[0-9]* david</tt></pre>\r
+</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+place the developers into the same git group.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+and make the shared repository writable by the group.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+use update-hook example by Carl from Documentation/howto/\r
for branch policy control.\r
-<b>(4)</b> alice and cindy can push into master, only bob can push into doc-update.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+alice and cindy can push into master, only bob can push into doc-update.\r
david is the release manager and is the only person who can\r
-create and push version tags.</tt></pre>\r
-</div></div>\r
+create and push version tags.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
<dt>\r
HTTP server to support dumb protocol transfer.\r
<div class="content">\r
<pre><tt>dev$ git update-server-info <b>(1)</b>\r
dev$ ftp user@isp.example.com <b>(2)</b>\r
-ftp> cp -r .git /home/user/myproject.git\r
-\r
-<b>(1)</b> make sure your info/refs and objects/info/packs are up-to-date\r
-<b>(2)</b> upload to public HTTP server hosted by your ISP.</tt></pre>\r
+ftp> cp -r .git /home/user/myproject.git</tt></pre>\r
</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+make sure your info/refs and objects/info/packs are up-to-date\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+upload to public HTTP server hosted by your ISP.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
</dl>\r
</div>\r
<div id="footer">\r
<div id="footer-text">\r
-Last updated 27-Dec-2005 00:17:10 PDT\r
+Last updated 29-Apr-2006 07:01:35 UTC\r
</div>\r
</div>\r
</body>\r
$ git count-objects <2>
$ git repack <3>
$ git prune <4>
-
+------------
++
<1> running without "--full" is usually cheap and assures the
repository health reasonably well.
<2> check how many loose objects there are and how much
<3> without "-a" repacks incrementally. repacking every 4-5MB
of loose objects accumulation may be a good rule of thumb.
<4> after repack, prune removes the duplicate loose objects.
-------------
Repack a small project into single pack.::
+
------------
$ git repack -a -d <1>
$ git prune
-
+------------
++
<1> pack all the objects reachable from the refs into one pack
and remove unneeded other packs
-------------
Individual Developer (Standalone)[[Individual Developer (Standalone)]]
$ git add . <1>
$ git commit -m 'import of frotz source tree.'
$ git tag v2.43 <2>
-
+------------
++
<1> add everything under the current directory.
<2> make a lightweight, unannotated tag.
-------------
Create a topic branch and develop.::
+
$ git pull . alsa-audio <10>
$ git log --since='3 days ago' <11>
$ git log v2.43.. curses/ <12>
-
+------------
++
<1> create a new topic branch.
<2> revert your botched changes in "curses/ux_audio_oss.c".
<3> you need to tell git if you added a new file; removal and
combined and include --max-count=10 (show 10 commits), --until='2005-12-10'.
<12> view only the changes that touch what's in curses/
directory, since v2.43 tag.
-------------
Individual Developer (Participant)[[Individual Developer (Participant)]]
$ git reset --hard ORIG_HEAD <6>
$ git prune <7>
$ git fetch --tags <8>
-
+------------
++
<1> repeat as needed.
<2> extract patches from your branch for e-mail submission.
<3> "pull" fetches from "origin" by default and merges into the
<7> garbage collect leftover objects from reverted pull.
<8> from time to time, obtain official tags from the "origin"
and store them under .git/refs/tags/.
-------------
Push into another repository.::
mothership$ cd frotz
mothership$ git checkout master
mothership$ git pull . satellite <5>
-
+------------
++
<1> mothership machine has a frotz repository under your home
directory; clone from it to start a repository on the satellite
machine.
mothership machine. You could use this as a back-up method.
<5> on mothership machine, merge the work done on the satellite
machine into the master branch.
-------------
Branch off of a specific tag.::
+
$ git checkout master
$ git format-patch -k -m --stdout v2.6.14..private2.6.14 |
git am -3 -k <2>
-
+------------
++
<1> create a private branch based on a well known (but somewhat behind)
tag.
<2> forward port all changes in private2.6.14 branch to master branch
without a formal "merging".
-------------
Integrator[[Integrator]]
$ git fetch ko && git show-branch master maint 'tags/ko-*' <11>
$ git push ko <12>
$ git push ko v0.99.9x <13>
-
+------------
++
<1> see what I was in the middle of doing, if any.
<2> see what topic branches I have and think about how ready
they are.
everything "ko-master" has.
<12> push out the bleeding edge.
<13> push the tag out, too.
-------------
Repository Administration[[Repository Administration]]
Examples
~~~~~~~~
-
Run git-daemon to serve /pub/scm from inetd.::
+
------------
david:x:1003:1003::/home/david:/usr/bin/git-shell
$ grep git /etc/shells <2>
/usr/bin/git-shell
-
+------------
++
<1> log-in shell is set to /usr/bin/git-shell, which does not
allow anything but "git push" and "git pull". The users should
get an ssh access to the machine.
<2> in many distributions /etc/shells needs to list what is used
as the login shell.
-------------
CVS-style shared repository.::
+
refs/heads/master alice\|cindy
refs/heads/doc-update bob
refs/tags/v[0-9]* david
-
+------------
++
<1> place the developers into the same git group.
<2> and make the shared repository writable by the group.
<3> use update-hook example by Carl from Documentation/howto/
<4> alice and cindy can push into master, only bob can push into doc-update.
david is the release manager and is the only person who can
create and push version tags.
-------------
HTTP server to support dumb protocol transfer.::
+
dev$ git update-server-info <1>
dev$ ftp user@isp.example.com <2>
ftp> cp -r .git /home/user/myproject.git
-
+------------
++
<1> make sure your info/refs and objects/info/packs are up-to-date
<2> upload to public HTTP server hosted by your ISP.
-------------
<h2>NAME</h2>\r
<div class="sectionbody">\r
<p>git-branch -\r
- Create a new branch, or remove an old one\r
+ List, create, or delete branches.\r
</p>\r
</div>\r
</div>\r
<h2>SYNOPSIS</h2>\r
<div class="sectionbody">\r
<div class="verseblock">\r
-<div class="content"><em>git-branch</em> [[-f] <branchname> [<start-point>]]\r
-<em>git-branch</em> (-d | -D) <branchname></div></div>\r
+<div class="content"><em>git-branch</em> [-r]\r
+<em>git-branch</em> [-f] <branchname> [<start-point>]\r
+<em>git-branch</em> (-d | -D) <branchname>…</div></div>\r
</div>\r
<h2>DESCRIPTION</h2>\r
<div class="sectionbody">\r
-<p>If no argument is provided, show available branches and mark current\r
-branch with star. Otherwise, create a new branch of name <branchname>.\r
-If a starting point is also specified, that will be where the branch is\r
-created, otherwise it will be created at the current HEAD.</p>\r
-<p>With a <tt>-d</tt> or <tt>-D</tt> option, <tt><branchname></tt> will be deleted.</p>\r
+<p>With no arguments given (or just <tt>-r</tt>) a list of available branches\r
+will be shown, the current branch will be highlighted with an asterisk.</p>\r
+<p>In its second form, a new branch named <branchname> will be created.\r
+It will start out with a head equal to the one given as <start-point>.\r
+If no <start-point> is given, the branch will be created with a head\r
+equal to that of the currently checked out branch.</p>\r
+<p>With a <tt>-d</tt> or <tt>-D</tt> option, <tt><branchname></tt> will be deleted. You may\r
+specify more than one branch for deletion.</p>\r
</div>\r
<h2>OPTIONS</h2>\r
<div class="sectionbody">\r
</dt>\r
<dd>\r
<p>\r
- Force a reset of <branchname> to <start-point> (or current head).\r
+ Force the creation of a new branch even if it means deleting\r
+ a branch that already exists with the same name.\r
+</p>\r
+</dd>\r
+<dt>\r
+-r\r
+</dt>\r
+<dd>\r
+<p>\r
+ List only the "remote" branches.\r
</p>\r
</dd>\r
<dt>\r
</dt>\r
<dd>\r
<p>\r
- Where to create the branch; defaults to HEAD. This\r
- option has no meaning with -d and -D.\r
+ The new branch will be created with a HEAD equal to this. It may\r
+ be given as a branch name, a commit-id, or a tag. If this option\r
+ is omitted, the current branch is assumed.\r
</p>\r
</dd>\r
</dl>\r
-<h3>Examples</h3>\r
+</div>\r
+<h2>Examples</h2>\r
+<div class="sectionbody">\r
<dl>\r
<dt>\r
Start development off of a known tag\r
<div class="content">\r
<pre><tt>$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6\r
$ cd my2.6\r
-$ git branch my2.6.14 v2.6.14 <b>(1)</b>\r
-$ git checkout my2.6.14\r
-\r
-<b>(1)</b> These two steps are the same as "checkout -b my2.6.14 v2.6.14".</tt></pre>\r
+$ git branch my2.6.14 v2.6.14 <b>(1)</b>\r
+$ git checkout my2.6.14</tt></pre>\r
</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+This step and the next one could be combined into a single step with\r
+"checkout -b my2.6.14 v2.6.14".\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
<dt>\r
Delete unneeded branch\r
<div class="content">\r
<pre><tt>$ git clone git://git.kernel.org/.../git.git my.git\r
$ cd my.git\r
-$ git branch -D todo <b>(1)</b>\r
-\r
-<b>(1)</b> delete todo branch even if the "master" branch does not have all\r
-commits from todo branch.</tt></pre>\r
+$ git branch -D todo <b>(1)</b></tt></pre>\r
</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+delete todo branch even if the "master" branch does not have all\r
+commits from todo branch.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
</dl>\r
</div>\r
+<h2>Notes</h2>\r
+<div class="sectionbody">\r
+<p>If you are creating a branch that you want to immediately checkout, it's\r
+easier to use the git checkout command with its <tt>-b</tt> option to create\r
+a branch and check it out with a single command.</p>\r
+</div>\r
<h2>Author</h2>\r
<div class="sectionbody">\r
<p>Written by Linus Torvalds <torvalds@osdl.org> and Junio C Hamano <junkio@cox.net></p>\r
</div>\r
<div id="footer">\r
<div id="footer-text">\r
-Last updated 18-Mar-2006 07:45:34 UTC\r
+Last updated 29-Apr-2006 07:01:32 UTC\r
</div>\r
</div>\r
</body>\r
NAME
----
-git-branch - Create a new branch, or remove an old one
+git-branch - List, create, or delete branches.
SYNOPSIS
--------
[verse]
-'git-branch' [[-f] <branchname> [<start-point>]]
-'git-branch' (-d | -D) <branchname>
+'git-branch' [-r]
+'git-branch' [-f] <branchname> [<start-point>]
+'git-branch' (-d | -D) <branchname>...
DESCRIPTION
-----------
-If no argument is provided, show available branches and mark current
-branch with star. Otherwise, create a new branch of name <branchname>.
-If a starting point is also specified, that will be where the branch is
-created, otherwise it will be created at the current HEAD.
+With no arguments given (or just `-r`) a list of available branches
+will be shown, the current branch will be highlighted with an asterisk.
-With a `-d` or `-D` option, `<branchname>` will be deleted.
+In its second form, a new branch named <branchname> will be created.
+It will start out with a head equal to the one given as <start-point>.
+If no <start-point> is given, the branch will be created with a head
+equal to that of the currently checked out branch.
+
+With a `-d` or `-D` option, `<branchname>` will be deleted. You may
+specify more than one branch for deletion.
OPTIONS
Delete a branch irrespective of its index status.
-f::
- Force a reset of <branchname> to <start-point> (or current head).
+ Force the creation of a new branch even if it means deleting
+ a branch that already exists with the same name.
+
+-r::
+ List only the "remote" branches.
<branchname>::
The name of the branch to create or delete.
<start-point>::
- Where to create the branch; defaults to HEAD. This
- option has no meaning with -d and -D.
+ The new branch will be created with a HEAD equal to this. It may
+ be given as a branch name, a commit-id, or a tag. If this option
+ is omitted, the current branch is assumed.
+
Examples
-~~~~~~~~
+--------
Start development off of a known tag::
+
------------
$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
$ cd my2.6
-$ git branch my2.6.14 v2.6.14 <1>
+$ git branch my2.6.14 v2.6.14 <1>
$ git checkout my2.6.14
-
-<1> These two steps are the same as "checkout -b my2.6.14 v2.6.14".
------------
++
+<1> This step and the next one could be combined into a single step with
+"checkout -b my2.6.14 v2.6.14".
Delete unneeded branch::
+
------------
$ git clone git://git.kernel.org/.../git.git my.git
$ cd my.git
-$ git branch -D todo <1>
-
+$ git branch -D todo <1>
+------------
++
<1> delete todo branch even if the "master" branch does not have all
commits from todo branch.
-------------
+
+
+Notes
+-----
+
+If you are creating a branch that you want to immediately checkout, it's
+easier to use the git checkout command with its `-b` option to create
+a branch and check it out with a single command.
+
Author
------
</p>\r
<div class="listingblock">\r
<div class="content">\r
-<pre><tt>$ git checkout master <b>(1)</b>\r
-$ git checkout master~2 Makefile <b>(2)</b>\r
+<pre><tt>$ git checkout master <b>(1)</b>\r
+$ git checkout master~2 Makefile <b>(2)</b>\r
$ rm -f hello.c\r
-$ git checkout hello.c <b>(3)</b>\r
-\r
-<b>(1)</b> switch branch\r
-<b>(2)</b> take out a file out of other commit\r
-<b>(3)</b> or "git checkout -- hello.c", as in the next example.</tt></pre>\r
+$ git checkout hello.c <b>(3)</b></tt></pre>\r
</div></div>\r
-<p>If you have an unfortunate branch that is named <tt>hello.c</tt>, the\r
-last step above would be confused as an instruction to switch to\r
-that branch. You should instead write:</p>\r
+<ol>\r
+<li>\r
+<p>\r
+switch branch\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+take out a file out of other commit\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+restore hello.c from HEAD of current branch\r
+</p>\r
+<p>If you have an unfortunate branch that is named <tt>hello.c</tt>, this\r
+step would be confused as an instruction to switch to that branch.\r
+You should instead write:</p>\r
<div class="listingblock">\r
<div class="content">\r
<pre><tt>$ git checkout -- hello.c</tt></pre>\r
</div></div>\r
</li>\r
+</ol>\r
+</li>\r
<li>\r
<p>\r
After working in a wrong branch, switching to the correct\r
</div>\r
<div id="footer">\r
<div id="footer-text">\r
-Last updated 18-Mar-2006 07:45:34 UTC\r
+Last updated 29-Apr-2006 07:01:33 UTC\r
</div>\r
</div>\r
</body>\r
mistake, and gets it back from the index.
+
------------
-$ git checkout master <1>
-$ git checkout master~2 Makefile <2>
+$ git checkout master <1>
+$ git checkout master~2 Makefile <2>
$ rm -f hello.c
-$ git checkout hello.c <3>
-
+$ git checkout hello.c <3>
+------------
++
<1> switch branch
<2> take out a file out of other commit
-<3> or "git checkout -- hello.c", as in the next example.
-------------
+<3> restore hello.c from HEAD of current branch
+
-If you have an unfortunate branch that is named `hello.c`, the
-last step above would be confused as an instruction to switch to
-that branch. You should instead write:
+If you have an unfortunate branch that is named `hello.c`, this
+step would be confused as an instruction to switch to that branch.
+You should instead write:
+
------------
$ git checkout -- hello.c
<dd>\r
<div class="listingblock">\r
<div class="content">\r
-<pre><tt>$ git diff <b>(1)</b>\r
-$ git diff --cached <b>(2)</b>\r
-$ git diff HEAD <b>(3)</b>\r
-\r
-<b>(1)</b> changes in the working tree since your last git-update-index.\r
-<b>(2)</b> changes between the index and your last commit; what you\r
-would be committing if you run "git commit" without "-a" option.\r
-<b>(3)</b> changes in the working tree since your last commit; what you\r
-would be committing if you run "git commit -a"</tt></pre>\r
+<pre><tt>$ git diff <b>(1)</b>\r
+$ git diff --cached <b>(2)</b>\r
+$ git diff HEAD <b>(3)</b></tt></pre>\r
</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+changes in the working tree since your last git-update-index.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+changes between the index and your last commit; what you\r
+would be committing if you run "git commit" without "-a" option.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+changes in the working tree since your last commit; what you\r
+would be committing if you run "git commit -a"\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
<dt>\r
Comparing with arbitrary commits\r
<dd>\r
<div class="listingblock">\r
<div class="content">\r
-<pre><tt>$ git diff test <b>(1)</b>\r
-$ git diff HEAD -- ./test <b>(2)</b>\r
-$ git diff HEAD^ HEAD <b>(3)</b>\r
-\r
-<b>(1)</b> instead of using the tip of the current branch, compare with the\r
+<pre><tt>$ git diff test <b>(1)</b>\r
+$ git diff HEAD -- ./test <b>(2)</b>\r
+$ git diff HEAD^ HEAD <b>(3)</b></tt></pre>\r
+</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+instead of using the tip of the current branch, compare with the\r
tip of "test" branch.\r
-<b>(2)</b> instead of comparing with the tip of "test" branch, compare with\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+instead of comparing with the tip of "test" branch, compare with\r
the tip of the current branch, but limit the comparison to the\r
file "test".\r
-<b>(3)</b> compare the version before the last commit and the last commit.</tt></pre>\r
-</div></div>\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+compare the version before the last commit and the last commit.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
<dt>\r
Limiting the diff output\r
<dd>\r
<div class="listingblock">\r
<div class="content">\r
-<pre><tt>$ git diff --diff-filter=MRC <b>(1)</b>\r
-$ git diff --name-status -r <b>(2)</b>\r
-$ git diff arch/i386 include/asm-i386 <b>(3)</b>\r
-\r
-<b>(1)</b> show only modification, rename and copy, but not addition\r
+<pre><tt>$ git diff --diff-filter=MRC <b>(1)</b>\r
+$ git diff --name-status -r <b>(2)</b>\r
+$ git diff arch/i386 include/asm-i386 <b>(3)</b></tt></pre>\r
+</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+show only modification, rename and copy, but not addition\r
nor deletion.\r
-<b>(2)</b> show only names and the nature of change, but not actual\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+show only names and the nature of change, but not actual\r
diff output. --name-status disables usual patch generation\r
which in turn also disables recursive behaviour, so without -r\r
you would only see the directory name if there is a change in a\r
file in a subdirectory.\r
-<b>(3)</b> limit diff output to named subtrees.</tt></pre>\r
-</div></div>\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+limit diff output to named subtrees.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
<dt>\r
Munging the diff output\r
<dd>\r
<div class="listingblock">\r
<div class="content">\r
-<pre><tt>$ git diff --find-copies-harder -B -C <b>(1)</b>\r
-$ git diff -R <b>(2)</b>\r
-\r
-<b>(1)</b> spend extra cycles to find renames, copies and complete\r
-rewrites (very expensive).\r
-<b>(2)</b> output diff in reverse.</tt></pre>\r
+<pre><tt>$ git diff --find-copies-harder -B -C <b>(1)</b>\r
+$ git diff -R <b>(2)</b></tt></pre>\r
</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+spend extra cycles to find renames, copies and complete\r
+rewrites (very expensive).\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+output diff in reverse.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
</dl>\r
</div>\r
</div>\r
<div id="footer">\r
<div id="footer-text">\r
-Last updated 10-Mar-2006 00:31:25 UTC\r
+Last updated 29-Apr-2006 07:01:33 UTC\r
</div>\r
</div>\r
</body>\r
Various ways to check your working tree::
+
------------
-$ git diff <1>
-$ git diff --cached <2>
-$ git diff HEAD <3>
-
+$ git diff <1>
+$ git diff --cached <2>
+$ git diff HEAD <3>
+------------
++
<1> changes in the working tree since your last git-update-index.
<2> changes between the index and your last commit; what you
would be committing if you run "git commit" without "-a" option.
<3> changes in the working tree since your last commit; what you
would be committing if you run "git commit -a"
-------------
Comparing with arbitrary commits::
+
------------
-$ git diff test <1>
-$ git diff HEAD -- ./test <2>
-$ git diff HEAD^ HEAD <3>
-
+$ git diff test <1>
+$ git diff HEAD -- ./test <2>
+$ git diff HEAD^ HEAD <3>
+------------
++
<1> instead of using the tip of the current branch, compare with the
tip of "test" branch.
<2> instead of comparing with the tip of "test" branch, compare with
the tip of the current branch, but limit the comparison to the
file "test".
<3> compare the version before the last commit and the last commit.
-------------
Limiting the diff output::
+
------------
-$ git diff --diff-filter=MRC <1>
-$ git diff --name-status -r <2>
-$ git diff arch/i386 include/asm-i386 <3>
-
+$ git diff --diff-filter=MRC <1>
+$ git diff --name-status -r <2>
+$ git diff arch/i386 include/asm-i386 <3>
+------------
++
<1> show only modification, rename and copy, but not addition
nor deletion.
<2> show only names and the nature of change, but not actual
you would only see the directory name if there is a change in a
file in a subdirectory.
<3> limit diff output to named subtrees.
-------------
Munging the diff output::
+
------------
-$ git diff --find-copies-harder -B -C <1>
-$ git diff -R <2>
-
+$ git diff --find-copies-harder -B -C <1>
+$ git diff -R <2>
+------------
++
<1> spend extra cycles to find renames, copies and complete
rewrites (very expensive).
<2> output diff in reverse.
-------------
Author
<div class="listingblock">\r
<div class="content">\r
<pre><tt>$ cd /path/to/my/codebase\r
-$ git-init-db <b>(1)</b>\r
-$ git-add . <b>(2)</b>\r
-\r
-<b>(1)</b> prepare /path/to/my/codebase/.git directory\r
-<b>(2)</b> add all existing file to the index</tt></pre>\r
+$ git-init-db <b>(1)</b>\r
+$ git-add . <b>(2)</b></tt></pre>\r
</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+prepare /path/to/my/codebase/.git directory\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+add all existing file to the index\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
</dl>\r
</div>\r
</div>\r
<div id="footer">\r
<div id="footer-text">\r
-Last updated 18-Mar-2006 07:45:35 UTC\r
+Last updated 29-Apr-2006 07:01:33 UTC\r
</div>\r
</div>\r
</body>\r
+
----------------
$ cd /path/to/my/codebase
-$ git-init-db <1>
-$ git-add . <2>
-
+$ git-init-db <1>
+$ git-add . <2>
+----------------
++
<1> prepare /path/to/my/codebase/.git directory
<2> add all existing file to the index
-----------------
Author
<h2>DESCRIPTION</h2>\r
<div class="sectionbody">\r
<p>Shows the commit logs.</p>\r
-<p>The command takes options applicable to the <a href=":git-rev-list.html">:git-rev-list(1)</a>\r
+<p>The command takes options applicable to the <a href="git-rev-list.html">git-rev-list(1)</a>\r
command to control what is shown and how, and options applicable to\r
-the <a href=":git-diff-tree.html">:git-diff-tree(1)</a> commands to control how the change\r
+the <a href="git-diff-tree.html">git-diff-tree(1)</a> commands to control how the change\r
each commit introduces are shown.</p>\r
-<p>This manual page describes only the most frequently used\r
-options.</p>\r
+<p>This manual page describes only the most frequently used options.</p>\r
</div>\r
<h2>OPTIONS</h2>\r
<div class="sectionbody">\r
</div>\r
<div id="footer">\r
<div id="footer-text">\r
-Last updated 15-Apr-2006 06:17:18 UTC\r
+Last updated 29-Apr-2006 07:01:34 UTC\r
</div>\r
</div>\r
</body>\r
-----------
Shows the commit logs.
-The command takes options applicable to the gitlink::git-rev-list[1]
+The command takes options applicable to the gitlink:git-rev-list[1]
command to control what is shown and how, and options applicable to
-the gitlink::git-diff-tree[1] commands to control how the change
+the gitlink:git-diff-tree[1] commands to control how the change
each commit introduces are shown.
-This manual page describes only the most frequently used
-options.
+This manual page describes only the most frequently used options.
OPTIONS
<div class="listingblock">\r
<div class="content">\r
<pre><tt>$ git commit ...\r
-$ git reset --soft HEAD^ <b>(1)</b>\r
-$ edit <b>(2)</b>\r
-$ git commit -a -c ORIG_HEAD <b>(3)</b>\r
-\r
-<b>(1)</b> This is most often done when you remembered what you\r
+$ git reset --soft HEAD^ <b>(1)</b>\r
+$ edit <b>(2)</b>\r
+$ git commit -a -c ORIG_HEAD <b>(3)</b></tt></pre>\r
+</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+This is most often done when you remembered what you\r
just committed is incomplete, or you misspelled your commit\r
message, or both. Leaves working tree as it was before "reset".\r
-<b>(2)</b> make corrections to working tree files.\r
-<b>(3)</b> "reset" copies the old head to .git/ORIG_HEAD; redo the\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+make corrections to working tree files.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+"reset" copies the old head to .git/ORIG_HEAD; redo the\r
commit by starting with its log message. If you do not need to\r
-edit the message further, you can give -C option instead.</tt></pre>\r
-</div></div>\r
+edit the message further, you can give -C option instead.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
<dt>\r
Undo commits permanently\r
<div class="listingblock">\r
<div class="content">\r
<pre><tt>$ git commit ...\r
-$ git reset --hard HEAD~3 <b>(1)</b>\r
-\r
-<b>(1)</b> The last three commits (HEAD, HEAD^, and HEAD~2) were bad\r
-and you do not want to ever see them again. Do *not* do this if\r
-you have already given these commits to somebody else.</tt></pre>\r
+$ git reset --hard HEAD~3 <b>(1)</b></tt></pre>\r
</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+The last three commits (HEAD, HEAD^, and HEAD~2) were bad\r
+and you do not want to ever see them again. Do <strong>not</strong> do this if\r
+you have already given these commits to somebody else.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
<dt>\r
Undo a commit, making it a topic branch\r
<dd>\r
<div class="listingblock">\r
<div class="content">\r
-<pre><tt>$ git branch topic/wip <b>(1)</b>\r
-$ git reset --hard HEAD~3 <b>(2)</b>\r
-$ git checkout topic/wip <b>(3)</b>\r
-\r
-<b>(1)</b> You have made some commits, but realize they were premature\r
+<pre><tt>$ git branch topic/wip <b>(1)</b>\r
+$ git reset --hard HEAD~3 <b>(2)</b>\r
+$ git checkout topic/wip <b>(3)</b></tt></pre>\r
+</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+You have made some commits, but realize they were premature\r
to be in the "master" branch. You want to continue polishing\r
them in a topic branch, so create "topic/wip" branch off of the\r
current HEAD.\r
-<b>(2)</b> Rewind the master branch to get rid of those three commits.\r
-<b>(3)</b> Switch to "topic/wip" branch and keep working.</tt></pre>\r
-</div></div>\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Rewind the master branch to get rid of those three commits.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+Switch to "topic/wip" branch and keep working.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
<dt>\r
Undo update-index\r
<dd>\r
<div class="listingblock">\r
<div class="content">\r
-<pre><tt>$ edit <b>(1)</b>\r
+<pre><tt>$ edit <b>(1)</b>\r
$ git-update-index frotz.c filfre.c\r
-$ mailx <b>(2)</b>\r
-$ git reset <b>(3)</b>\r
-$ git pull git://info.example.com/ nitfol <b>(4)</b>\r
-\r
-<b>(1)</b> you are happily working on something, and find the changes\r
+$ mailx <b>(2)</b>\r
+$ git reset <b>(3)</b>\r
+$ git pull git://info.example.com/ nitfol <b>(4)</b></tt></pre>\r
+</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+you are happily working on something, and find the changes\r
in these files are in good order. You do not want to see them\r
when you run "git diff", because you plan to work on other files\r
and changes with these files are distracting.\r
-<b>(2)</b> somebody asks you to pull, and the changes sounds worthy of merging.\r
-<b>(3)</b> however, you already dirtied the index (i.e. your index does\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+somebody asks you to pull, and the changes sounds worthy of merging.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+however, you already dirtied the index (i.e. your index does\r
not match the HEAD commit). But you know the pull you are going\r
to make does not affect frotz.c nor filfre.c, so you revert the\r
index changes for these two files. Your changes in working tree\r
remain there.\r
-<b>(4)</b> then you can pull and merge, leaving frotz.c and filfre.c\r
-changes still in the working tree.</tt></pre>\r
-</div></div>\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+then you can pull and merge, leaving frotz.c and filfre.c\r
+changes still in the working tree.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
<dt>\r
Undo a merge or pull\r
<dd>\r
<div class="listingblock">\r
<div class="content">\r
-<pre><tt>$ git pull <b>(1)</b>\r
+<pre><tt>$ git pull <b>(1)</b>\r
Trying really trivial in-index merge...\r
fatal: Merge requires file-level merging\r
Nope.\r
Auto-merging nitfol\r
CONFLICT (content): Merge conflict in nitfol\r
Automatic merge failed/prevented; fix up by hand\r
-$ git reset --hard <b>(2)</b>\r
-\r
-<b>(1)</b> try to update from the upstream resulted in a lot of\r
+$ git reset --hard <b>(2)</b>\r
+$ git pull . topic/branch <b>(3)</b>\r
+Updating from 41223... to 13134...\r
+Fast forward\r
+$ git reset --hard ORIG_HEAD <b>(4)</b></tt></pre>\r
+</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+try to update from the upstream resulted in a lot of\r
conflicts; you were not ready to spend a lot of time merging\r
right now, so you decide to do that later.\r
-<b>(2)</b> "pull" has not made merge commit, so "git reset --hard"\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+"pull" has not made merge commit, so "git reset --hard"\r
which is a synonym for "git reset --hard HEAD" clears the mess\r
from the index file and the working tree.\r
-\r
-$ git pull . topic/branch <b>(3)</b>\r
-Updating from 41223... to 13134...\r
-Fast forward\r
-$ git reset --hard ORIG_HEAD <b>(4)</b>\r
-\r
-<b>(3)</b> merge a topic branch into the current branch, which resulted\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+merge a topic branch into the current branch, which resulted\r
in a fast forward.\r
-<b>(4)</b> but you decided that the topic branch is not ready for public\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+but you decided that the topic branch is not ready for public\r
consumption yet. "pull" or "merge" always leaves the original\r
tip of the current branch in ORIG_HEAD, so resetting hard to it\r
brings your index file and the working tree back to that state,\r
-and resets the tip of the branch to that commit.</tt></pre>\r
-</div></div>\r
+and resets the tip of the branch to that commit.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
<dt>\r
Interrupted workflow\r
<div class="content">\r
<pre><tt>$ git checkout feature ;# you were working in "feature" branch and\r
$ work work work ;# got interrupted\r
-$ git commit -a -m 'snapshot WIP' <b>(1)</b>\r
+$ git commit -a -m 'snapshot WIP' <b>(1)</b>\r
$ git checkout master\r
$ fix fix fix\r
$ git commit ;# commit with real log\r
$ git checkout feature\r
-$ git reset --soft HEAD^ ;# go back to WIP state <b>(2)</b>\r
-$ git reset <b>(3)</b>\r
-\r
-<b>(1)</b> This commit will get blown away so a throw-away log message is OK.\r
-<b>(2)</b> This removes the 'WIP' commit from the commit history, and sets\r
- your working tree to the state just before you made that snapshot.\r
-<b>(3)</b> After <b>(2)</b>, the index file still has all the WIP changes you\r
- committed in <b>(1)</b>. This sets it to the last commit you were\r
- basing the WIP changes on.</tt></pre>\r
+$ git reset --soft HEAD^ ;# go back to WIP state <b>(2)</b>\r
+$ git reset <b>(3)</b></tt></pre>\r
</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+This commit will get blown away so a throw-away log message is OK.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+This removes the <em>WIP</em> commit from the commit history, and sets\r
+ your working tree to the state just before you made that snapshot.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+At this point the index file still has all the WIP changes you\r
+ committed as <em>snapshot WIP</em>. This updates the index to show your\r
+ WIP files as uncommitted.\r
+</p>\r
+</li>\r
+</ol>\r
</dd>\r
</dl>\r
</div>\r
</div>\r
<div id="footer">\r
<div id="footer-text">\r
-Last updated 10-Mar-2006 00:31:34 UTC\r
+Last updated 29-Apr-2006 07:01:34 UTC\r
</div>\r
</div>\r
</body>\r
+
------------
$ git commit ...
-$ git reset --soft HEAD^ <1>
-$ edit <2>
-$ git commit -a -c ORIG_HEAD <3>
-
+$ git reset --soft HEAD^ <1>
+$ edit <2>
+$ git commit -a -c ORIG_HEAD <3>
+------------
++
<1> This is most often done when you remembered what you
just committed is incomplete, or you misspelled your commit
message, or both. Leaves working tree as it was before "reset".
<3> "reset" copies the old head to .git/ORIG_HEAD; redo the
commit by starting with its log message. If you do not need to
edit the message further, you can give -C option instead.
-------------
Undo commits permanently::
+
------------
$ git commit ...
-$ git reset --hard HEAD~3 <1>
-
+$ git reset --hard HEAD~3 <1>
+------------
++
<1> The last three commits (HEAD, HEAD^, and HEAD~2) were bad
and you do not want to ever see them again. Do *not* do this if
you have already given these commits to somebody else.
-------------
Undo a commit, making it a topic branch::
+
------------
-$ git branch topic/wip <1>
-$ git reset --hard HEAD~3 <2>
-$ git checkout topic/wip <3>
-
+$ git branch topic/wip <1>
+$ git reset --hard HEAD~3 <2>
+$ git checkout topic/wip <3>
+------------
++
<1> You have made some commits, but realize they were premature
to be in the "master" branch. You want to continue polishing
them in a topic branch, so create "topic/wip" branch off of the
current HEAD.
<2> Rewind the master branch to get rid of those three commits.
<3> Switch to "topic/wip" branch and keep working.
-------------
Undo update-index::
+
------------
-$ edit <1>
+$ edit <1>
$ git-update-index frotz.c filfre.c
-$ mailx <2>
-$ git reset <3>
-$ git pull git://info.example.com/ nitfol <4>
-
+$ mailx <2>
+$ git reset <3>
+$ git pull git://info.example.com/ nitfol <4>
+------------
++
<1> you are happily working on something, and find the changes
in these files are in good order. You do not want to see them
when you run "git diff", because you plan to work on other files
remain there.
<4> then you can pull and merge, leaving frotz.c and filfre.c
changes still in the working tree.
-------------
Undo a merge or pull::
+
------------
-$ git pull <1>
+$ git pull <1>
Trying really trivial in-index merge...
fatal: Merge requires file-level merging
Nope.
Auto-merging nitfol
CONFLICT (content): Merge conflict in nitfol
Automatic merge failed/prevented; fix up by hand
-$ git reset --hard <2>
-
+$ git reset --hard <2>
+$ git pull . topic/branch <3>
+Updating from 41223... to 13134...
+Fast forward
+$ git reset --hard ORIG_HEAD <4>
+------------
++
<1> try to update from the upstream resulted in a lot of
conflicts; you were not ready to spend a lot of time merging
right now, so you decide to do that later.
<2> "pull" has not made merge commit, so "git reset --hard"
which is a synonym for "git reset --hard HEAD" clears the mess
from the index file and the working tree.
-
-$ git pull . topic/branch <3>
-Updating from 41223... to 13134...
-Fast forward
-$ git reset --hard ORIG_HEAD <4>
-
<3> merge a topic branch into the current branch, which resulted
in a fast forward.
<4> but you decided that the topic branch is not ready for public
tip of the current branch in ORIG_HEAD, so resetting hard to it
brings your index file and the working tree back to that state,
and resets the tip of the branch to that commit.
-------------
Interrupted workflow::
+
------------
$ git checkout feature ;# you were working in "feature" branch and
$ work work work ;# got interrupted
-$ git commit -a -m 'snapshot WIP' <1>
+$ git commit -a -m 'snapshot WIP' <1>
$ git checkout master
$ fix fix fix
$ git commit ;# commit with real log
$ git checkout feature
-$ git reset --soft HEAD^ ;# go back to WIP state <2>
-$ git reset <3>
-
+$ git reset --soft HEAD^ ;# go back to WIP state <2>
+$ git reset <3>
+------------
++
<1> This commit will get blown away so a throw-away log message is OK.
<2> This removes the 'WIP' commit from the commit history, and sets
your working tree to the state just before you made that snapshot.
-<3> After <2>, the index file still has all the WIP changes you
- committed in <1>. This sets it to the last commit you were
- basing the WIP changes on.
-------------
+<3> At this point the index file still has all the WIP changes you
+ committed as 'snapshot WIP'. This updates the index to show your
+ WIP files as uncommitted.
Author
------
<div class="content">\r
<pre><tt>$ git-checkout-index -n -f -a && git-update-index --ignore-missing --refresh</tt></pre>\r
</div></div>\r
-<p>On an inefficient filesystem with <tt>core.ignorestat</tt> set:</p>\r
+<dl>\r
+<dt>\r
+On an inefficient filesystem with <tt>core.ignorestat</tt> set\r
+</dt>\r
+<dd>\r
<div class="listingblock">\r
<div class="content">\r
-<pre><tt>$ git update-index --really-refresh <b>(1)</b>\r
-$ git update-index --no-assume-unchanged foo.c <b>(2)</b>\r
-$ git diff --name-only <b>(3)</b>\r
+<pre><tt>$ git update-index --really-refresh <b>(1)</b>\r
+$ git update-index --no-assume-unchanged foo.c <b>(2)</b>\r
+$ git diff --name-only <b>(3)</b>\r
$ edit foo.c\r
-$ git diff --name-only <b>(4)</b>\r
+$ git diff --name-only <b>(4)</b>\r
M foo.c\r
-$ git update-index foo.c <b>(5)</b>\r
-$ git diff --name-only <b>(6)</b>\r
+$ git update-index foo.c <b>(5)</b>\r
+$ git diff --name-only <b>(6)</b>\r
$ edit foo.c\r
-$ git diff --name-only <b>(7)</b>\r
-$ git update-index --no-assume-unchanged foo.c <b>(8)</b>\r
-$ git diff --name-only <b>(9)</b>\r
-M foo.c\r
-\r
-<b>(1)</b> forces lstat(2) to set "assume unchanged" bits for paths\r
- that match index.\r
-<b>(2)</b> mark the path to be edited.\r
-<b>(3)</b> this does lstat(2) and finds index matches the path.\r
-<b>(4)</b> this does lstat(2) and finds index does not match the path.\r
-<b>(5)</b> registering the new version to index sets "assume unchanged" bit.\r
-<b>(6)</b> and it is assumed unchanged.\r
-<b>(7)</b> even after you edit it.\r
-<b>(8)</b> you can tell about the change after the fact.\r
-<b>(9)</b> now it checks with lstat(2) and finds it has been changed.</tt></pre>\r
+$ git diff --name-only <b>(7)</b>\r
+$ git update-index --no-assume-unchanged foo.c <b>(8)</b>\r
+$ git diff --name-only <b>(9)</b>\r
+M foo.c</tt></pre>\r
</div></div>\r
+<ol>\r
+<li>\r
+<p>\r
+forces lstat(2) to set "assume unchanged" bits for paths that match index.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+mark the path to be edited.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+this does lstat(2) and finds index matches the path.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+this does lstat(2) and finds index does <strong>not</strong> match the path.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+registering the new version to index sets "assume unchanged" bit.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+and it is assumed unchanged.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+even after you edit it.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+you can tell about the change after the fact.\r
+</p>\r
+</li>\r
+<li>\r
+<p>\r
+now it checks with lstat(2) and finds it has been changed.\r
+</p>\r
+</li>\r
+</ol>\r
+</dd>\r
+</dl>\r
</div>\r
<h2>Configuration</h2>\r
<div class="sectionbody">\r
</div>\r
<div id="footer">\r
<div id="footer-text">\r
-Last updated 22-Feb-2006 10:44:48 UTC\r
+Last updated 29-Apr-2006 07:01:35 UTC\r
</div>\r
</div>\r
</body>\r
$ git-checkout-index -n -f -a && git-update-index --ignore-missing --refresh
----------------
-On an inefficient filesystem with `core.ignorestat` set:
-
+On an inefficient filesystem with `core.ignorestat` set::
++
------------
-$ git update-index --really-refresh <1>
-$ git update-index --no-assume-unchanged foo.c <2>
-$ git diff --name-only <3>
+$ git update-index --really-refresh <1>
+$ git update-index --no-assume-unchanged foo.c <2>
+$ git diff --name-only <3>
$ edit foo.c
-$ git diff --name-only <4>
+$ git diff --name-only <4>
M foo.c
-$ git update-index foo.c <5>
-$ git diff --name-only <6>
+$ git update-index foo.c <5>
+$ git diff --name-only <6>
$ edit foo.c
-$ git diff --name-only <7>
-$ git update-index --no-assume-unchanged foo.c <8>
-$ git diff --name-only <9>
+$ git diff --name-only <7>
+$ git update-index --no-assume-unchanged foo.c <8>
+$ git diff --name-only <9>
M foo.c
-
-<1> forces lstat(2) to set "assume unchanged" bits for paths
- that match index.
+------------
++
+<1> forces lstat(2) to set "assume unchanged" bits for paths that match index.
<2> mark the path to be edited.
<3> this does lstat(2) and finds index matches the path.
-<4> this does lstat(2) and finds index does not match the path.
+<4> this does lstat(2) and finds index does *not* match the path.
<5> registering the new version to index sets "assume unchanged" bit.
<6> and it is assumed unchanged.
<7> even after you edit it.
<8> you can tell about the change after the fact.
<9> now it checks with lstat(2) and finds it has been changed.
-------------
Configuration