├── .gitignore ├── LICENSE.md ├── NOTES ├── README.md ├── _config.yml ├── _layouts ├── reference.html └── zh_reference.html ├── about.html ├── basic └── index.html ├── branching └── index.html ├── cookbook.html ├── creating └── index.html ├── css ├── 960.css ├── grid.css ├── ie.css ├── ie6.css ├── layout.css ├── nav.css ├── reset.css └── text.css ├── favicon.ico ├── favicon.png ├── images └── snapshots.png ├── index.html ├── inspect └── index.html ├── js ├── action.js ├── jquery-1.4.1.min.js └── jquery-ui.min.js ├── remotes └── index.html └── zh ├── .gitignore ├── about.html ├── basic └── index.html ├── branching └── index.html ├── cookbook.html ├── creating └── index.html ├── images └── snapshots.png ├── index.html ├── inspect └── index.html └── remotes └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | _site 2 | *~ 3 | .*.swp 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # License 2 | The prose, course text, slide layouts, class outlines, diagrams, HTML, CSS, and Markdown code in the set of educational materials located in this repository are licensed as _CC BY 3.0_. The Octocat, GitHub logo and other already-copyrighted and already-reserved trademarks and images are not covered by this license. 3 | 4 | ------------------------ 5 | 6 | # Attribution 3.0 Unported (CC BY 3.0) 7 | This is a [human-readable summary](http://creativecommons.org/licenses/by/3.0/deed.en_US) of the [Legal Code (the full license)](http://creativecommons.org/licenses/by/3.0/legalcode). 8 | 9 | 10 | ## You are free: 11 | 12 | * to Share — to copy, distribute and transmit the work 13 | * to Remix — to adapt the work 14 | to make commercial use of the work 15 | 16 | 17 | ## Under the following conditions: 18 | 19 | * Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). 20 | 21 | ## With the understanding that: 22 | 23 | * Waiver — Any of the above conditions can be waived if you get permission from the copyright holder. 24 | * Public Domain — Where the work or any of its elements is in the public domain under applicable law, that status is in no way affected by the license. 25 | * Other Rights — In no way are any of the following rights affected by the license: 26 | * Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations; 27 | * The author's moral rights; 28 | * Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights. 29 | 30 | Notice — For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page. 31 | 32 | -------------------------------- 33 | 34 | # Attribution 3.0 Unported (CC BY 3.0) 35 | 36 | http://creativecommons.org/licenses/by/3.0/legalcode 37 | 38 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM ITS USE. 39 | 40 | License 41 | 42 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. 43 | 44 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. 45 | 46 | 1. Definitions 47 | 48 | "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License. 49 | "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License. 50 | "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership. 51 | "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License. 52 | "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast. 53 | "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work. 54 | "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. 55 | "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images. 56 | "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium. 57 | 2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws. 58 | 59 | 3. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: 60 | 61 | to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; 62 | to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified."; 63 | to Distribute and Publicly Perform the Work including as incorporated in Collections; and, 64 | to Distribute and Publicly Perform Adaptations. 65 | 66 | For the avoidance of doubt: 67 | Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; 68 | Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and, 69 | Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License. 70 | 71 | The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved. 72 | 73 | 4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: 74 | 75 | You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(b), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(b), as requested. 76 | If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and (iv) , consistent with Section 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4 (b) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties. 77 | Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise. 78 | 79 | 5. Representations, Warranties and Disclaimer 80 | 81 | UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 82 | 83 | 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 84 | 85 | 7. Termination 86 | 87 | This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. 88 | Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. 89 | 8. Miscellaneous 90 | 91 | Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. 92 | Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License. 93 | If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. 94 | No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. 95 | This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. 96 | The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law. 97 | 98 | Creative Commons Notice 99 | 100 | Creative Commons is not a party to this License, and makes no warranty whatsoever in connection with the Work. Creative Commons will not be liable to You or any party on any legal theory for any damages whatsoever, including without limitation any general, special, incidental or consequential damages arising in connection to this license. Notwithstanding the foregoing two (2) sentences, if Creative Commons has expressly identified itself as the Licensor hereunder, it shall have all rights and obligations of Licensor. 101 | Except for the limited purpose of indicating to the public that the Work is licensed under the CCPL, Creative Commons does not authorize the use by either party of the trademark "Creative Commons" or any related trademark or logo of Creative Commons without the prior written consent of Creative Commons. Any permitted use will be in compliance with Creative Commons' then-current trademark usage guidelines, as may be published on its website or otherwise made available upon request from time to time. For the avoidance of doubt, this trademark restriction does not form part of this License. 102 | 103 | Creative Commons may be contacted at http://creativecommons.org/. 104 | -------------------------------------------------------------------------------- /NOTES: -------------------------------------------------------------------------------- 1 | Introduction 2 | (how git is different) 3 | 4 | Getting & Creating Projects 5 | * init 6 | * clone 7 | 8 | Basic Snapshotting 9 | * add 10 | * status 11 | * diff 12 | * commit 13 | * rm, mv 14 | * reset 15 | 16 | Branching and Merging Contexts 17 | * branch 18 | * merge 19 | * cherry-pick 20 | * log 21 | 22 | Sharing and Updating Projects 23 | * fetch, pull 24 | * push 25 | 26 | Inspection, Comparison and History 27 | * log 28 | * diff 29 | 30 | Fixing History 31 | * rebase 32 | * revert 33 | 34 | 35 |
36 |

My Note

37 | this note is pretty cool. 38 | this note is pretty cool. 39 |
40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Online Git Reference 2 | 3 | Quick reference guide of basic Git commands along with examples of 4 | common uses and options. 5 | 6 | Each section includes tasks related to the type of operation you 7 | may be trying to do. 8 | 9 | If you would like to know more about a command listed, each command 10 | links to both the official manual page and its relevant chapter 11 | in the [Pro Git book](http://git-scm.com/book). 12 | 13 | ## Contributing 14 | 15 | If you would like to contribute, simply fork the repository, push 16 | your changes to a branch and send a pull request. 17 | 18 | Typo fixes, improvements to grammar or readability, it's all welcome. -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | baseurl: /git-reference 2 | -------------------------------------------------------------------------------- /_layouts/reference.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Git Reference 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |
21 | Git Reference 22 |
23 | 24 |
25 | 32 |
33 |   34 |
35 | 36 |
37 |
38 |

Getting and Creating Projects

39 | 43 |
44 | 45 |
46 |

Basic Snapshotting

47 | 56 |
57 | 58 |
59 |

Branching and Merging

60 | 67 |
68 | 69 |
70 |

Sharing and Updating Projects

71 | 76 |
77 | 78 |
79 |

Inspection and Comparison

80 | 84 |
85 | 86 | 98 |
99 | 100 |
101 | {{ content }} 102 |
103 | 104 |
105 |
106 | 107 | 108 | -------------------------------------------------------------------------------- /_layouts/zh_reference.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Git 参考手册 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |
21 | Git 参考手册 22 |
23 | 24 |
25 | 32 |
33 |   34 |
35 | 36 |
37 |
38 |

获取与创建项目

39 | 43 |
44 | 45 |
46 |

基本的快照

47 | 55 |
56 | 57 |
58 |

分支与合并

59 | 66 |
67 | 68 |
69 |

分享与更新项目

70 | 75 |
76 | 77 |
78 |

检查与比较

79 | 83 |
84 | 85 | 97 |
98 | 99 |
100 | {{ content }} 101 |
102 | 103 |
104 |
105 | 106 | 107 | -------------------------------------------------------------------------------- /about.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: reference 3 | --- 4 |
5 |

Who Did This?

6 |
7 |

The Git Reference site was put together by the GitHub 8 | team.

9 |
10 | -------------------------------------------------------------------------------- /cookbook.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: reference 3 | --- 4 |
5 |

Git Cookbook

6 | 12 |
13 | -------------------------------------------------------------------------------- /creating/index.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: reference 3 | --- 4 | 5 |
6 |

Getting and Creating Projects

7 |
8 |

9 | In order to do anything in Git, you need to have a Git repository. This 10 | is where Git stores the data for the snapshots you are saving. 11 |

12 | 13 |

14 | There are two main ways to get a Git repository. One way is to simply 15 | initialize a new one from an existing directory, such as a new project or 16 | a project new to source control. The second way is to clone one from a 17 | public Git repository, as you would do if you wanted a copy or wanted to 18 | work with someone on a project. We will cover both of these here. 19 |

20 | 21 |
22 |
23 | 24 |
25 |

26 | 27 | docs   28 | book 29 | 30 | git init 31 | initializes a directory as a Git repository 32 |

33 | 34 |
35 |

To create a repository from an existing directory of files, you can 36 | simply run git init in that directory. For example, 37 | let's say we have a directory with a few files in it, like this: 38 |

39 | 40 |
 41 | $ cd konnichiwa
 42 | $ ls
 43 | README   hello.rb
 44 | 
45 | 46 |

This is a project where we are writing examples of the "Hello World" 47 | program in every language. So far, we just have Ruby, but hey, it's 48 | a start. To start version controlling this with Git, we can simply 49 | run git init. 50 |

51 | 52 |
 53 | $ git init
 54 | Initialized empty Git repository in /opt/konnichiwa/.git/
 55 | 
56 | 57 |

Now you can see that there is a .git subdirectory in your 58 | project. This is your Git repository where all the data of your 59 | project snapshots are stored. 60 |

61 | 62 |
 63 | $ ls -a
 64 | .        ..       .git     README   hello.rb
 65 | 
66 | 67 |

Congratulations, you now have a skeleton Git repository and can start 68 | snapshotting your project. 69 |

70 | 71 |

72 | In a nutshell, you use git init to make an 73 | existing directory of content into a new Git repository. You can do this 74 | in any directory at any time, completely locally.

75 | 76 |
77 |
78 | 79 |
80 |

81 | 82 | docs   83 | book 84 | 85 | git clone 86 | copy a git repository so you can add to it 87 |

88 |
89 |

90 | If you need to collaborate with someone on a project, or if you want to 91 | get a copy of a project so you can look at or use the code, you will 92 | clone it. You simply run the git clone [url] command with 93 | the URL of the project you want to copy. 94 |

95 | 96 |
 97 | $ git clone git://github.com/schacon/simplegit.git
 98 | Initialized empty Git repository in /private/tmp/simplegit/.git/
 99 | remote: Counting objects: 100, done.
100 | remote: Compressing objects: 100% (86/86), done.
101 | remote: Total 100 (delta 35), reused 0 (delta 0)
102 | Receiving objects: 100% (100/100), 9.51 KiB, done.
103 | Resolving deltas: 100% (35/35), done.
104 | $ cd simplegit/
105 | $ ls
106 | README   Rakefile lib
107 | 
108 | 109 |

110 | This will copy the entire history of that project so you have it locally 111 | and it will give you a working directory of the main branch of that project 112 | so you can look at the code or start editing it. If you change into the 113 | new directory, you can see the .git subdirectory - that is 114 | where all the project data is. 115 |

116 | 117 |
118 | $ ls -a
119 | .        ..       .git     README   Rakefile lib
120 | $ cd .git
121 | $ ls
122 | HEAD        description info        packed-refs
123 | branches    hooks       logs        refs
124 | config      index       objects
125 | 
126 | 127 |

128 | By default, Git will create a directory that is the same name as the 129 | project in the URL you give it - basically whatever is after the last slash 130 | of the URL. If you want something different, you can just put it at the 131 | end of the command, after the URL. 132 |

133 | 134 |

135 | In a nutshell, you use git clone to get a 136 | local copy of a Git repository so you can look at it or start modifying 137 | it.

138 | 139 |
140 |
141 | 142 |

On to Basic Snapshotting »

143 | -------------------------------------------------------------------------------- /css/960.css: -------------------------------------------------------------------------------- 1 | /* 2 | 960 Grid System ~ Core CSS. 3 | Learn more ~ http://960.gs/ 4 | 5 | Licensed under GPL and MIT. 6 | */ 7 | 8 | /* =Containers 9 | --------------------------------------------------------------------------------*/ 10 | 11 | .container_12, 12 | .container_16 13 | { 14 | margin-left: auto; 15 | margin-right: auto; 16 | width: 960px; 17 | } 18 | 19 | /* =Grid >> Global 20 | --------------------------------------------------------------------------------*/ 21 | 22 | .grid_1, 23 | .grid_2, 24 | .grid_3, 25 | .grid_4, 26 | .grid_5, 27 | .grid_6, 28 | .grid_7, 29 | .grid_8, 30 | .grid_9, 31 | .grid_10, 32 | .grid_11, 33 | .grid_12, 34 | .grid_13, 35 | .grid_14, 36 | .grid_15, 37 | .grid_16 38 | { 39 | display: inline; 40 | float: left; 41 | margin-left: 10px; 42 | margin-right: 10px; 43 | } 44 | 45 | .container_12 .grid_3, 46 | .container_16 .grid_4 47 | { 48 | width: 220px; 49 | } 50 | 51 | .container_12 .grid_6, 52 | .container_16 .grid_8 53 | { 54 | width: 460px; 55 | } 56 | 57 | .container_12 .grid_9, 58 | .container_16 .grid_12 59 | { 60 | width: 700px; 61 | } 62 | 63 | .container_12 .grid_12, 64 | .container_16 .grid_16 65 | { 66 | width: 940px; 67 | } 68 | 69 | /* =Grid >> Children (Alpha ~ First, Omega ~ Last) 70 | --------------------------------------------------------------------------------*/ 71 | 72 | .alpha 73 | { 74 | margin-left: 0; 75 | } 76 | 77 | .omega 78 | { 79 | margin-right: 0; 80 | } 81 | 82 | /* =Grid >> 12 Columns 83 | --------------------------------------------------------------------------------*/ 84 | 85 | .container_12 .grid_1 86 | { 87 | width: 60px; 88 | } 89 | 90 | .container_12 .grid_2 91 | { 92 | width: 140px; 93 | } 94 | 95 | .container_12 .grid_4 96 | { 97 | width: 300px; 98 | } 99 | 100 | .container_12 .grid_5 101 | { 102 | width: 380px; 103 | } 104 | 105 | .container_12 .grid_7 106 | { 107 | width: 540px; 108 | } 109 | 110 | .container_12 .grid_8 111 | { 112 | width: 620px; 113 | } 114 | 115 | .container_12 .grid_10 116 | { 117 | width: 780px; 118 | } 119 | 120 | .container_12 .grid_11 121 | { 122 | width: 860px; 123 | } 124 | 125 | /* =Grid >> 16 Columns 126 | --------------------------------------------------------------------------------*/ 127 | 128 | .container_16 .grid_1 129 | { 130 | width: 40px; 131 | } 132 | 133 | .container_16 .grid_2 134 | { 135 | width: 100px; 136 | } 137 | 138 | .container_16 .grid_3 139 | { 140 | width: 160px; 141 | } 142 | 143 | .container_16 .grid_5 144 | { 145 | width: 280px; 146 | } 147 | 148 | .container_16 .grid_6 149 | { 150 | width: 340px; 151 | } 152 | 153 | .container_16 .grid_7 154 | { 155 | width: 400px; 156 | } 157 | 158 | .container_16 .grid_9 159 | { 160 | width: 520px; 161 | } 162 | 163 | .container_16 .grid_10 164 | { 165 | width: 580px; 166 | } 167 | 168 | .container_16 .grid_11 169 | { 170 | width: 640px; 171 | } 172 | 173 | .container_16 .grid_13 174 | { 175 | width: 760px; 176 | } 177 | 178 | .container_16 .grid_14 179 | { 180 | width: 820px; 181 | } 182 | 183 | .container_16 .grid_15 184 | { 185 | width: 880px; 186 | } 187 | 188 | /* =Prefix Extra Space >> Global 189 | --------------------------------------------------------------------------------*/ 190 | 191 | .container_12 .prefix_3, 192 | .container_16 .prefix_4 193 | { 194 | padding-left: 240px; 195 | } 196 | 197 | .container_12 .prefix_6, 198 | .container_16 .prefix_8 199 | { 200 | padding-left: 480px; 201 | } 202 | 203 | .container_12 .prefix_9, 204 | .container_16 .prefix_12 205 | { 206 | padding-left: 720px; 207 | } 208 | 209 | /* =Prefix Extra Space >> 12 Columns 210 | --------------------------------------------------------------------------------*/ 211 | 212 | .container_12 .prefix_1 213 | { 214 | padding-left: 80px; 215 | } 216 | 217 | .container_12 .prefix_2 218 | { 219 | padding-left: 160px; 220 | } 221 | 222 | .container_12 .prefix_4 223 | { 224 | padding-left: 320px; 225 | } 226 | 227 | .container_12 .prefix_5 228 | { 229 | padding-left: 400px; 230 | } 231 | 232 | .container_12 .prefix_7 233 | { 234 | padding-left: 560px; 235 | } 236 | 237 | .container_12 .prefix_8 238 | { 239 | padding-left: 640px; 240 | } 241 | 242 | .container_12 .prefix_10 243 | { 244 | padding-left: 800px; 245 | } 246 | 247 | .container_12 .prefix_11 248 | { 249 | padding-left: 880px; 250 | } 251 | 252 | /* =Prefix Extra Space >> 16 Columns 253 | --------------------------------------------------------------------------------*/ 254 | 255 | .container_16 .prefix_1 256 | { 257 | padding-left: 60px; 258 | } 259 | 260 | .container_16 .prefix_2 261 | { 262 | padding-left: 120px; 263 | } 264 | 265 | .container_16 .prefix_3 266 | { 267 | padding-left: 180px; 268 | } 269 | 270 | .container_16 .prefix_5 271 | { 272 | padding-left: 300px; 273 | } 274 | 275 | .container_16 .prefix_6 276 | { 277 | padding-left: 360px; 278 | } 279 | 280 | .container_16 .prefix_7 281 | { 282 | padding-left: 420px; 283 | } 284 | 285 | .container_16 .prefix_9 286 | { 287 | padding-left: 540px; 288 | } 289 | 290 | .container_16 .prefix_10 291 | { 292 | padding-left: 600px; 293 | } 294 | 295 | .container_16 .prefix_11 296 | { 297 | padding-left: 660px; 298 | } 299 | 300 | .container_16 .prefix_13 301 | { 302 | padding-left: 780px; 303 | } 304 | 305 | .container_16 .prefix_14 306 | { 307 | padding-left: 840px; 308 | } 309 | 310 | .container_16 .prefix_15 311 | { 312 | padding-left: 900px; 313 | } 314 | 315 | /* =Suffix Extra Space >> Global 316 | --------------------------------------------------------------------------------*/ 317 | 318 | .container_12 .suffix_3, 319 | .container_16 .suffix_4 320 | { 321 | padding-right: 240px; 322 | } 323 | 324 | .container_12 .suffix_6, 325 | .container_16 .suffix_8 326 | { 327 | padding-right: 480px; 328 | } 329 | 330 | .container_12 .suffix_9, 331 | .container_16 .suffix_12 332 | { 333 | padding-right: 720px; 334 | } 335 | 336 | /* =Suffix Extra Space >> 12 Columns 337 | --------------------------------------------------------------------------------*/ 338 | 339 | .container_12 .suffix_1 340 | { 341 | padding-right: 80px; 342 | } 343 | 344 | .container_12 .suffix_2 345 | { 346 | padding-right: 160px; 347 | } 348 | 349 | .container_12 .suffix_4 350 | { 351 | padding-right: 320px; 352 | } 353 | 354 | .container_12 .suffix_5 355 | { 356 | padding-right: 400px; 357 | } 358 | 359 | .container_12 .suffix_7 360 | { 361 | padding-right: 560px; 362 | } 363 | 364 | .container_12 .suffix_8 365 | { 366 | padding-right: 640px; 367 | } 368 | 369 | .container_12 .suffix_10 370 | { 371 | padding-right: 800px; 372 | } 373 | 374 | .container_12 .suffix_11 375 | { 376 | padding-right: 880px; 377 | } 378 | 379 | /* =Suffix Extra Space >> 16 Columns 380 | --------------------------------------------------------------------------------*/ 381 | 382 | .container_16 .suffix_1 383 | { 384 | padding-right: 60px; 385 | } 386 | 387 | .container_16 .suffix_2 388 | { 389 | padding-right: 120px; 390 | } 391 | 392 | .container_16 .suffix_3 393 | { 394 | padding-right: 180px; 395 | } 396 | 397 | .container_16 .suffix_5 398 | { 399 | padding-right: 300px; 400 | } 401 | 402 | .container_16 .suffix_6 403 | { 404 | padding-right: 360px; 405 | } 406 | 407 | .container_16 .suffix_7 408 | { 409 | padding-right: 420px; 410 | } 411 | 412 | .container_16 .suffix_9 413 | { 414 | padding-right: 540px; 415 | } 416 | 417 | .container_16 .suffix_10 418 | { 419 | padding-right: 600px; 420 | } 421 | 422 | .container_16 .suffix_11 423 | { 424 | padding-right: 660px; 425 | } 426 | 427 | .container_16 .suffix_13 428 | { 429 | padding-right: 780px; 430 | } 431 | 432 | .container_16 .suffix_14 433 | { 434 | padding-right: 840px; 435 | } 436 | 437 | .container_16 .suffix_15 438 | { 439 | padding-right: 900px; 440 | } 441 | 442 | /* =Clear Floated Elements 443 | --------------------------------------------------------------------------------*/ 444 | 445 | /* http://sonspring.com/journal/clearing-floats */ 446 | 447 | html body * span.clear, 448 | html body * div.clear, 449 | html body * li.clear, 450 | html body * dd.clear 451 | { 452 | background: none; 453 | border: 0; 454 | clear: both; 455 | display: block; 456 | float: none; 457 | font-size: 0; 458 | list-style: none; 459 | margin: 0; 460 | padding: 0; 461 | overflow: hidden; 462 | visibility: hidden; 463 | width: 0; 464 | height: 0; 465 | } 466 | 467 | /* http://www.positioniseverything.net/easyclearing.html */ 468 | 469 | .clearfix:after 470 | { 471 | clear: both; 472 | content: '.'; 473 | display: block; 474 | visibility: hidden; 475 | height: 0; 476 | } 477 | 478 | .clearfix 479 | { 480 | display: inline-block; 481 | } 482 | 483 | * html .clearfix 484 | { 485 | height: 1%; 486 | } 487 | 488 | .clearfix 489 | { 490 | display: block; 491 | } -------------------------------------------------------------------------------- /css/grid.css: -------------------------------------------------------------------------------- 1 | /* 2 | 960 Grid System ~ Core CSS. 3 | Learn more ~ http://960.gs/ 4 | 5 | Licensed under GPL and MIT. 6 | */ 7 | 8 | /* =Containers 9 | --------------------------------------------------------------------------------*/ 10 | 11 | .container_12, 12 | .container_16 13 | { 14 | width: 92%; 15 | margin-left: 4%; 16 | margin-right: 4%; 17 | } 18 | 19 | /* =Grid >> Global 20 | --------------------------------------------------------------------------------*/ 21 | 22 | .grid_1, 23 | .grid_2, 24 | .grid_3, 25 | .grid_4, 26 | .grid_5, 27 | .grid_6, 28 | .grid_7, 29 | .grid_8, 30 | .grid_9, 31 | .grid_10, 32 | .grid_11, 33 | .grid_12, 34 | .grid_13, 35 | .grid_14, 36 | .grid_15, 37 | .grid_16 38 | { 39 | display: inline; 40 | float: left; 41 | margin-left: 1%; 42 | margin-right: 1%; 43 | } 44 | 45 | .container_12 .grid_3, 46 | .container_16 .grid_4 47 | { 48 | width: 23%; 49 | } 50 | 51 | .container_12 .grid_6, 52 | .container_16 .grid_8 53 | { 54 | width: 48%; 55 | } 56 | 57 | .container_12 .grid_9, 58 | .container_16 .grid_12 59 | { 60 | width: 73%; 61 | } 62 | 63 | .container_12 .grid_12, 64 | .container_16 .grid_16 65 | { 66 | width: 98%; 67 | } 68 | 69 | /* =Grid >> Children (Alpha ~ First, Omega ~ Last) 70 | --------------------------------------------------------------------------------*/ 71 | 72 | .alpha 73 | { 74 | margin-left: 0; 75 | } 76 | 77 | .omega 78 | { 79 | margin-right: 0; 80 | } 81 | 82 | /* =Grid >> 12 Columns 83 | --------------------------------------------------------------------------------*/ 84 | 85 | .container_12 .grid_1 86 | { 87 | width: 6.333%; 88 | } 89 | 90 | .container_12 .grid_2 91 | { 92 | width: 14.666%; 93 | } 94 | 95 | .container_12 .grid_4 96 | { 97 | width: 31.333%; 98 | } 99 | 100 | .container_12 .grid_5 101 | { 102 | width: 39.666%; 103 | } 104 | 105 | .container_12 .grid_7 106 | { 107 | width: 56.333%; 108 | } 109 | 110 | .container_12 .grid_8 111 | { 112 | width: 64.666%; 113 | } 114 | 115 | .container_12 .grid_10 116 | { 117 | width: 81.333%; 118 | } 119 | 120 | .container_12 .grid_11 121 | { 122 | width: 89.666%; 123 | } 124 | 125 | /* =Grid >> 16 Columns 126 | --------------------------------------------------------------------------------*/ 127 | 128 | .container_16 .grid_1 129 | { 130 | width: 4.25%; 131 | } 132 | 133 | .container_16 .grid_2 134 | { 135 | width: 10.5%; 136 | } 137 | 138 | .container_16 .grid_3 139 | { 140 | width: 16.75%; 141 | } 142 | 143 | .container_16 .grid_5 144 | { 145 | width: 29.25%; 146 | } 147 | 148 | .container_16 .grid_6 149 | { 150 | width: 35.5%; 151 | } 152 | 153 | .container_16 .grid_7 154 | { 155 | width: 41.75%; 156 | } 157 | 158 | .container_16 .grid_9 159 | { 160 | width: 54.25%; 161 | } 162 | 163 | .container_16 .grid_10 164 | { 165 | width: 60.5%; 166 | } 167 | 168 | .container_16 .grid_11 169 | { 170 | width: 66.75%; 171 | } 172 | 173 | .container_16 .grid_13 174 | { 175 | width: 79.25%; 176 | } 177 | 178 | .container_16 .grid_14 179 | { 180 | width: 85.5%; 181 | } 182 | 183 | .container_16 .grid_15 184 | { 185 | width: 91.75%; 186 | } 187 | 188 | /* =Prefix Extra Space >> Global 189 | --------------------------------------------------------------------------------*/ 190 | 191 | .container_12 .prefix_3, 192 | .container_16 .prefix_4 193 | { 194 | padding-left: 25%; 195 | } 196 | 197 | .container_12 .prefix_6, 198 | .container_16 .prefix_8 199 | { 200 | padding-left: 50%; 201 | } 202 | 203 | .container_12 .prefix_9, 204 | .container_16 .prefix_12 205 | { 206 | padding-left: 75%; 207 | } 208 | 209 | /* =Prefix Extra Space >> 12 Columns 210 | --------------------------------------------------------------------------------*/ 211 | 212 | .container_12 .prefix_1 213 | { 214 | padding-left: 8.333%; 215 | } 216 | 217 | .container_12 .prefix_2 218 | { 219 | padding-left: 16.666%; 220 | } 221 | 222 | .container_12 .prefix_4 223 | { 224 | padding-left: 33.333%; 225 | } 226 | 227 | .container_12 .prefix_5 228 | { 229 | padding-left: 41.666%; 230 | } 231 | 232 | .container_12 .prefix_7 233 | { 234 | padding-left: 58.333%; 235 | } 236 | 237 | .container_12 .prefix_8 238 | { 239 | padding-left: 66.666%; 240 | } 241 | 242 | .container_12 .prefix_10 243 | { 244 | padding-left: 83.333%; 245 | } 246 | 247 | .container_12 .prefix_11 248 | { 249 | padding-left: 91.666%; 250 | } 251 | 252 | /* =Prefix Extra Space >> 16 Columns 253 | --------------------------------------------------------------------------------*/ 254 | 255 | .container_16 .prefix_1 256 | { 257 | padding-left: 6.25%; 258 | } 259 | 260 | .container_16 .prefix_2 261 | { 262 | padding-left: 12.5%; 263 | } 264 | 265 | .container_16 .prefix_3 266 | { 267 | padding-left: 18.75%; 268 | } 269 | 270 | .container_16 .prefix_5 271 | { 272 | padding-left: 31.25%; 273 | } 274 | 275 | .container_16 .prefix_6 276 | { 277 | padding-left: 37.5%; 278 | } 279 | 280 | .container_16 .prefix_7 281 | { 282 | padding-left: 43.75%; 283 | } 284 | 285 | .container_16 .prefix_9 286 | { 287 | padding-left: 56.25%; 288 | } 289 | 290 | .container_16 .prefix_10 291 | { 292 | padding-left: 62.5%; 293 | } 294 | 295 | .container_16 .prefix_11 296 | { 297 | padding-left: 68.75%; 298 | } 299 | 300 | .container_16 .prefix_13 301 | { 302 | padding-left: 81.25%; 303 | } 304 | 305 | .container_16 .prefix_14 306 | { 307 | padding-left: 87.5%; 308 | } 309 | 310 | .container_16 .prefix_15 311 | { 312 | padding-left: 93.75%; 313 | } 314 | 315 | /* =Suffix Extra Space >> Global 316 | --------------------------------------------------------------------------------*/ 317 | 318 | .container_12 .suffix_3, 319 | .container_16 .suffix_4 320 | { 321 | padding-right: 25%; 322 | } 323 | 324 | .container_12 .suffix_6, 325 | .container_16 .suffix_8 326 | { 327 | padding-right: 50%; 328 | } 329 | 330 | .container_12 .suffix_9, 331 | .container_16 .suffix_12 332 | { 333 | padding-right: 75%; 334 | } 335 | 336 | /* =Suffix Extra Space >> 12 Columns 337 | --------------------------------------------------------------------------------*/ 338 | 339 | .container_12 .suffix_1 340 | { 341 | padding-right: 8.333%; 342 | } 343 | 344 | .container_12 .suffix_2 345 | { 346 | padding-right: 16.666%; 347 | } 348 | 349 | .container_12 .suffix_4 350 | { 351 | padding-right: 33.333%; 352 | } 353 | 354 | .container_12 .suffix_5 355 | { 356 | padding-right: 41.666%; 357 | } 358 | 359 | .container_12 .suffix_7 360 | { 361 | padding-right: 58.333%; 362 | } 363 | 364 | .container_12 .suffix_8 365 | { 366 | padding-right: 66.666%; 367 | } 368 | 369 | .container_12 .suffix_10 370 | { 371 | padding-right: 83.333%; 372 | } 373 | 374 | .container_12 .suffix_11 375 | { 376 | padding-right: 91.666%; 377 | } 378 | 379 | /* =Suffix Extra Space >> 16 Columns 380 | --------------------------------------------------------------------------------*/ 381 | 382 | .container_16 .suffix_1 383 | { 384 | padding-right: 6.25%; 385 | } 386 | 387 | .container_16 .suffix_2 388 | { 389 | padding-right: 16.5%; 390 | } 391 | 392 | .container_16 .suffix_3 393 | { 394 | padding-right: 18.75%; 395 | } 396 | 397 | .container_16 .suffix_5 398 | { 399 | padding-right: 31.25%; 400 | } 401 | 402 | .container_16 .suffix_6 403 | { 404 | padding-right: 37.5%; 405 | } 406 | 407 | .container_16 .suffix_7 408 | { 409 | padding-right: 43.75%; 410 | } 411 | 412 | .container_16 .suffix_9 413 | { 414 | padding-right: 56.25%; 415 | } 416 | 417 | .container_16 .suffix_10 418 | { 419 | padding-right: 62.5%; 420 | } 421 | 422 | .container_16 .suffix_11 423 | { 424 | padding-right: 68.75%; 425 | } 426 | 427 | .container_16 .suffix_13 428 | { 429 | padding-right: 81.25%; 430 | } 431 | 432 | .container_16 .suffix_14 433 | { 434 | padding-right: 87.5%; 435 | } 436 | 437 | .container_16 .suffix_15 438 | { 439 | padding-right: 93.75%; 440 | } 441 | 442 | /* =Clear Floated Elements 443 | --------------------------------------------------------------------------------*/ 444 | 445 | /* http://sonspring.com/journal/clearing-floats */ 446 | 447 | html body * span.clear, 448 | html body * div.clear, 449 | html body * li.clear, 450 | html body * dd.clear 451 | { 452 | background: none; 453 | border: 0; 454 | clear: both; 455 | display: block; 456 | float: none; 457 | font-size: 0; 458 | list-style: none; 459 | margin: 0; 460 | padding: 0; 461 | overflow: hidden; 462 | visibility: hidden; 463 | width: 0; 464 | height: 0; 465 | } 466 | 467 | /* http://www.positioniseverything.net/easyclearing.html */ 468 | 469 | .clearfix:after 470 | { 471 | clear: both; 472 | content: '.'; 473 | display: block; 474 | visibility: hidden; 475 | height: 0; 476 | } 477 | 478 | .clearfix 479 | { 480 | display: inline-block; 481 | } 482 | 483 | * html .clearfix 484 | { 485 | height: 1%; 486 | } 487 | 488 | .clearfix 489 | { 490 | display: block; 491 | } -------------------------------------------------------------------------------- /css/ie.css: -------------------------------------------------------------------------------- 1 | /* 2 | Fluid 960 Grid System - IE Fixes (IE7 and greater) 3 | Learn more ~ http://www.designinfluences.com/ 4 | 5 | Licensed under GPL and MIT. 6 | */ 7 | 8 | /* =Grid >> Global 9 | --------------------------------------------------------------------------------*/ 10 | 11 | .grid_1, 12 | .grid_2, 13 | .grid_3, 14 | .grid_4, 15 | .grid_5, 16 | .grid_6, 17 | .grid_7, 18 | .grid_8, 19 | .grid_9, 20 | .grid_10, 21 | .grid_11, 22 | .grid_12, 23 | .grid_13, 24 | .grid_14, 25 | .grid_15, 26 | .grid_16 27 | { 28 | margin-left: .92%; 29 | margin-right: .92%; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /css/ie6.css: -------------------------------------------------------------------------------- 1 | /* 2 | Fluid 960 Grid System - IE6 Fixes 3 | Learn more ~ http://www.designinfluences.com/ 4 | 5 | Licensed under GPL and MIT. 6 | */ 7 | 8 | /* =Grid >> Global 9 | --------------------------------------------------------------------------------*/ 10 | 11 | .grid_1, 12 | .grid_2, 13 | .grid_3, 14 | .grid_4, 15 | .grid_5, 16 | .grid_6, 17 | .grid_7, 18 | .grid_8, 19 | .grid_9, 20 | .grid_10, 21 | .grid_11, 22 | .grid_12, 23 | .grid_13, 24 | .grid_14, 25 | .grid_15, 26 | .grid_16 27 | { 28 | margin-left: .8%; 29 | margin-right: .8%; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /css/layout.css: -------------------------------------------------------------------------------- 1 | /* 2 | ----------------------------------------------- 3 | Grey Box Method - Layout CSS 4 | ----------------------------------------------- */ 5 | 6 | html, body { 7 | border-top: 5px solid #000; 8 | color: #333; 9 | padding: 0 0 40px; 10 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 11 | } 12 | 13 | #about_me img { border: 5px solid #333; margin: 3px; } 14 | 15 | .info { background: #fff; padding: 10px;} 16 | 17 | .article { border-bottom: 5px solid rgb(20,120,200); padding-bottom: 10px; margin-bottom: 15px;} 18 | 19 | .non_home_box { 20 | display: none; 21 | } 22 | 23 | #reflist h3 { 24 | font-size: 1.1em; 25 | background: #fff; 26 | } 27 | #reflist h3 a { 28 | color: rgb(20,120,200); 29 | } 30 | #reflist h4 { font-size: 0.9em; } 31 | #reflist .block { margin: 0; padding: 0; } 32 | 33 | code { background: #ffe; padding: 2px 5px; } 34 | 35 | p.nutshell { 36 | background: #ddd; 37 | padding: 5px; 38 | } 39 | 40 | .box pre { 41 | margin-top: 10px; 42 | padding: 8px; 43 | background: #ffe; 44 | color: #555; 45 | } 46 | 47 | .box code.code { 48 | white-space:pre; 49 | font-family: Consolas, 'Liberation Mono', Courier, monospace; 50 | padding: 8px; 51 | background: #ffe; 52 | display: block; 53 | margin: 10px; 54 | color: #555; 55 | } 56 | pre b { color: #111; } 57 | .red { color: #d33; } 58 | .green { color: #383; } 59 | .umber { color: #8A3324; } 60 | .lblue { color: #55a; } 61 | .blue { color: #447; } 62 | .yellow { color: #993; } 63 | .hl { background: #eea; } 64 | 65 | .box h4 { 66 | font-family: Consolas, 'Liberation Mono', Courier, monospace; 67 | margin-top: 20px; 68 | color: #833; 69 | } 70 | .box h4 small { 71 | color: #888; 72 | font-size: 0.8em; 73 | margin-left: 10px; 74 | font-weight: normal; 75 | } 76 | 77 | .note { 78 | float: right; 79 | border: 10px; 80 | padding: 8px; 81 | background: #dfd; 82 | border: 1px solid #8a8; 83 | width: 120px; 84 | } 85 | .note h3 { 86 | font-size: 1.1em; 87 | color: #353; 88 | } 89 | 90 | ul#menu { 91 | background: rgb(20,120,200); 92 | padding: .5em; 93 | display: inline; 94 | color: #fff; 95 | } 96 | ul#menu li { 97 | border: 0; 98 | margin: 0; 99 | padding: 0; 100 | padding-right: 10px; 101 | padding-left: 10px; 102 | display:inline; 103 | font-size: 1.1em; 104 | } 105 | 106 | ul#menu li a { color: #fff; } 107 | 108 | .scribble-preview { 109 | background: #ff9; 110 | padding: 8px; 111 | border: 1px solid #ee6; 112 | } 113 | 114 | img#me { border: 8px solid #333; } 115 | 116 | /* anchors 117 | ----------------------------------------------- */ 118 | a { 119 | color: #000; 120 | font-weight:bold; 121 | text-decoration: none; 122 | } 123 | a:hover { 124 | color:#333; 125 | } 126 | a.page-button { 127 | background: #e4eafa none 0 0 repeat-x; 128 | border: solid 1px #c9172e; 129 | color: #c9172e; 130 | cursor: pointer; 131 | display: inline-block; 132 | font-weight: bold; 133 | font-size: 12px; 134 | line-height: 100%; 135 | margin: 1px; 136 | padding: 0.8em 1em; 137 | position: relative; 138 | text-decoration: none; 139 | text-shadow: #fff 0 1px 0; 140 | vertical-align: middle; 141 | white-space: nowrap; 142 | float:right; 143 | background-image: -moz-linear-gradient(-90deg, 144 | #eeeeee 1%, 145 | #fdf6f7 5%, 146 | #fae9eb 70%, 147 | #f7dcdf 100%); 148 | background-image: -webkit-gradient(linear,left top,left bottom, 149 | color-stop(0.01, #eee), 150 | color-stop(0.05, #fdf6f7), 151 | color-stop(0.70, #fae9eb), 152 | color-stop(1, #f7dcdf)); 153 | } 154 | a.next-page { 155 | border-right: none; 156 | margin-right: 26px; 157 | padding-right: 0; 158 | } 159 | a.next-page:after, a.prev-page:after { 160 | border: solid 1px #c9172e; 161 | content: ''; 162 | display: block; 163 | position: absolute; 164 | top: .37em; 165 | width: 1.7em; 166 | height: 1.7em; 167 | text-shadow: none; 168 | z-index: -1; 169 | } 170 | a.next-page:after { 171 | right: -.97em; 172 | -moz-transform: rotate(-45deg); 173 | background-image: -moz-linear-gradient(-135deg, 174 | #eeeeee 1%, 175 | #fdf6f7 5%, 176 | #fae9eb 70%, 177 | #f7dcdf 100%); 178 | -webkit-transform:rotate(-45deg); 179 | background-image: -webkit-gradient(linear,100% 0%, 0% 100%, 180 | color-stop(0.01, #eee), 181 | color-stop(0.05, #fdf6f7), 182 | color-stop(0.70, #fae9eb), 183 | color-stop(1, #f7dcdf)); 184 | } 185 | 186 | /* headings 187 | ----------------------------------------------- */ 188 | h1, h2, h3, h4, h5, h6 {line-height:1.2em; margin-bottom:.3em;} 189 | h2 {margin-top:1em; } 190 | h5 {font-size:1.2em;} 191 | h6 {font-size:1em; text-transform:uppercase;} 192 | h3 { color: rgb(20,120,200); } 193 | 194 | h1 a { 195 | font-weight:normal; 196 | } 197 | 198 | 199 | /* branding 200 | ----------------------------------------------- */ 201 | #branding { 202 | font-weight:normal; 203 | font-size:4em; 204 | text-align:left; 205 | padding:8px; 206 | margin-bottom:0; 207 | color: #333; 208 | } 209 | 210 | 211 | /* page heading 212 | ----------------------------------------------- */ 213 | #page-heading { 214 | padding: 5px; 215 | background: #000; 216 | color: #eee; 217 | font-size:2em; 218 | letter-spacing: 8px; 219 | } 220 | 221 | 222 | /* boxes 223 | ----------------------------------------------- */ 224 | .box { 225 | background:#eee; 226 | margin-bottom:20px; 227 | padding:10px 10px 1px 10px; 228 | font-size: 1.1em; 229 | } 230 | .box h2 { 231 | font-size:1em; 232 | font-weight:normal; 233 | text-transform:uppercase; 234 | color:#fff; 235 | background:#333; 236 | margin:-10px -10px 0 -10px; 237 | padding:6px 12px; 238 | } 239 | .box h2 .desc { 240 | margin-left: 20px; 241 | text-transform:none; 242 | color: #aaa; 243 | } 244 | .box h2 a, 245 | .box h2 a.visible { 246 | background-color:#111; 247 | color:#fff; 248 | display:inline; 249 | padding:6px 12px; 250 | margin:-6px -12px; 251 | border:none; 252 | text-transform:none; 253 | } 254 | .box h2 .docs { 255 | color: #999; 256 | display:inline; 257 | float: right; 258 | background-color:#333; 259 | } 260 | .box h2 .docs a { 261 | background-color:#333; 262 | padding:0; 263 | margin:0; 264 | } 265 | 266 | .grid_4 .box h2 a { 267 | background-position: 97% 50%; 268 | } 269 | .grid_5 .box h2 a { 270 | background-position: 98% 50%; 271 | } 272 | .grid_12 .box h2 a { 273 | background-position: 99% 50%; 274 | } 275 | 276 | 277 | .box h2 a:hover { 278 | background-color:#111; 279 | } 280 | .block { 281 | padding-top:10px; 282 | } 283 | div.menu { 284 | padding:0; 285 | } 286 | div.menu h2 { 287 | margin:0; 288 | } 289 | div.menu .block { 290 | padding-top:0; 291 | } 292 | 293 | 294 | /* paragraphs, quotes and lists 295 | ----------------------------------------------- */ 296 | p { 297 | margin-bottom:1em; 298 | } 299 | blockquote { 300 | font-family: Consolas, 'Liberation Mono', Courier, monospace; 301 | padding-left:1em; 302 | border-left:4px solid #ccc; 303 | } 304 | blockquote cite { 305 | font-size:.9em; 306 | } 307 | ul, ol { 308 | padding-top:0; 309 | } 310 | 311 | 312 | /* menus 313 | ----------------------------------------------- */ 314 | ul.menu { 315 | list-style:none; 316 | border-top:1px solid #bbb; 317 | } 318 | ul.menu li { 319 | margin:0; 320 | } 321 | ul.menu li a { 322 | display:block; 323 | padding:4px 10px; 324 | border-bottom:1px solid #ccc; 325 | } 326 | ul.menu li a:hover { 327 | background:#eee; 328 | } 329 | ul.menu li a:active { 330 | background:#ccc; 331 | } 332 | 333 | 334 | /* submenus 335 | ----------------------------------------------- */ 336 | ul.menu ul { 337 | list-style:none; 338 | margin:0; 339 | } 340 | ul.menu ul li a { 341 | padding-left:30px; 342 | } 343 | 344 | 345 | /* section menus 346 | ----------------------------------------------- */ 347 | ul.section { 348 | border-top:0; 349 | margin-bottom:0; 350 | } 351 | ul.section li { 352 | text-transform:uppercase; 353 | } 354 | ul.section li a { 355 | background:#bbb; 356 | } 357 | ul.section li a:hover { 358 | background:#aaa; 359 | } 360 | ul.section li a:active { 361 | color:#fff; 362 | background:#666; 363 | } 364 | ul.section li li a { 365 | background:#ddd; 366 | border-bottom:1px solid #eee; 367 | } 368 | ul.section li li a:hover { 369 | background:#ccc; 370 | } 371 | ul.section li li a:active { 372 | color:#000; 373 | background:#fff; 374 | } 375 | ul.section ul li { 376 | text-transform:none; 377 | } 378 | ul.section ul.current li a { 379 | background:#eee; 380 | border-bottom:1px solid #fff; 381 | } 382 | ul.section ul.current li a:hover { 383 | background:#ddd; 384 | } 385 | ul.section ul.current li a:active { 386 | background:#fff; 387 | } 388 | ul.section li a.current { 389 | color:#fff; 390 | background:#666; 391 | } 392 | ul.section li a.current:hover { 393 | background:#555; 394 | } 395 | ul.section li a.current:active { 396 | background:#444; 397 | } 398 | ul.section li a.active { 399 | background:#fff; 400 | cursor:default; 401 | } 402 | ul.section li.current > a.active, 403 | ul.section li.current > a.active:hover { 404 | color:#fff; 405 | background:#666; 406 | cursor:default; 407 | } 408 | 409 | 410 | /* table 411 | ----------------------------------------------- */ 412 | table { 413 | width:100%; 414 | border:1px solid #bbb; 415 | margin-bottom:10px; 416 | } 417 | col.colC { 418 | width:8em; 419 | } 420 | th, td { 421 | padding:.2em 1em; 422 | text-align:left; 423 | } 424 | thead th { 425 | border-bottom:2px solid #888; 426 | background:#bbb; 427 | padding:.4em 1em .2em; 428 | } 429 | thead th.table-head { 430 | font-size:1em; 431 | font-weight:normal; 432 | text-transform:uppercase; 433 | color:#fff; 434 | background:#555; 435 | border:1px solid #555; 436 | } 437 | tbody th, 438 | tbody td { 439 | border-top:1px solid #bbb; 440 | border-bottom:1px solid #bbb; 441 | background:#eee; 442 | } 443 | tbody tr.odd th, 444 | tbody tr.odd td { 445 | background:#fff; 446 | } 447 | tfoot th, 448 | tfoot td { 449 | border-top:2px solid #666; 450 | background:#eee; 451 | } 452 | tfoot tr.total th, 453 | tfoot tr.total td { 454 | border-top:6px double #666; 455 | } 456 | tfoot tr.total th { 457 | text-transform:uppercase; 458 | } 459 | th.currency, 460 | td.currency { 461 | text-align:right; 462 | } 463 | 464 | 465 | /* forms 466 | ----------------------------------------------- */ 467 | form { 468 | overflow:hidden; 469 | } 470 | fieldset { 471 | border:1px solid #bbb; 472 | padding:10px; 473 | position:relative; 474 | background:#e9e9e9; 475 | margin-bottom:10px; 476 | } 477 | legend { 478 | font-size:1.1em; 479 | padding:.4em .8em; 480 | background:#fff; 481 | border:1px solid #bbb; 482 | } 483 | fieldset.login p { 484 | margin-bottom:1em; 485 | margin-top:0pt; 486 | } 487 | fieldset p label { 488 | width:98%; 489 | } 490 | fieldset p input { 491 | width:98%; 492 | } 493 | fieldset p select { 494 | width:99%; 495 | } 496 | fieldset.login p label { 497 | float:left; 498 | line-height:2em; 499 | margin-right:3%; 500 | text-align:right; 501 | width:32%; 502 | } 503 | fieldset.login p input { 504 | width:60%; 505 | } 506 | fieldset.login input.button { 507 | margin-left:35%; 508 | } 509 | form p.notice { 510 | font-weight:bold; 511 | } 512 | input.search.text { 513 | width:66%; 514 | } 515 | input.search.button { 516 | width:28%; 517 | margin-left:2%; 518 | } 519 | 520 | 521 | /* articles 522 | ----------------------------------------------- */ 523 | .articles { 524 | padding:0; 525 | } 526 | .articles h2 { 527 | margin:0; 528 | } 529 | #articles { 530 | padding-top:0; 531 | } 532 | .article { 533 | border-top:1px solid #666; 534 | padding-top:.5em; 535 | } 536 | .box .article { 537 | border-top:3px solid #fff; 538 | padding:13px 10px 0 10px; 539 | background: #fff; 540 | } 541 | .article h2 { 542 | font-size:2em; 543 | font-weight:normal; 544 | text-transform:none; 545 | color:#333; 546 | background:transparent; 547 | padding:0; 548 | margin:0; 549 | border:none; 550 | } 551 | .article h3 { 552 | margin-bottom:.2em; 553 | font-size:1.6em; 554 | } 555 | .box .first { 556 | border-top:none; 557 | } 558 | .article h4 { 559 | font-size:1.2em; 560 | text-transform:uppercase; 561 | margin-bottom:.5em; 562 | } 563 | .article a.image { 564 | float:left; 565 | margin:3px 10px 3px 0; 566 | padding:4px; 567 | border:1px solid #bbb; 568 | background:#fff; 569 | } 570 | .article a.image:hover { 571 | border:1px solid #666; 572 | } 573 | .article a.image img { 574 | float:left; 575 | } 576 | .article p.meta { 577 | color:#666; 578 | border-top:1px dotted #999; 579 | border-bottom:1px dotted #999; 580 | padding:.3em 0; 581 | margin-bottom:.8em; 582 | } 583 | 584 | 585 | /* site information 586 | ----------------------------------------------- */ 587 | #site_info .box { 588 | color:#ccc; 589 | background:#666; 590 | margin-bottom:10px; 591 | } 592 | #site_info a { 593 | color:#fff; 594 | } 595 | #site_info a:hover { 596 | color:#000; 597 | } 598 | 599 | 600 | /* AJAX sliding shelf 601 | ----------------------------------------------- */ 602 | #loading {float:right; margin-right:14px; margin-top:-2px;} 603 | .block {padding-bottom:1px;} 604 | 605 | 606 | /* Accordian 607 | ----------------------------------------------- */ 608 | .toggler { 609 | color: #222; 610 | margin: 0; 611 | padding: 2px 5px; 612 | background: #eee; 613 | border-bottom: 1px solid #ddd; 614 | border-right: 1px solid #ddd; 615 | border-top: 1px solid #f5f5f5; 616 | border-left: 1px solid #f5f5f5; 617 | font-size:1.1em; 618 | font-weight: normal; 619 | } 620 | .element h4 { 621 | margin: 0; 622 | padding:4px; 623 | line-height:1.2em; 624 | } 625 | .element p { 626 | margin: 0; 627 | padding: 4px; 628 | } 629 | .float-right { 630 | padding:10px 20px; 631 | float:right; 632 | } 633 | 634 | #accordian-block { 635 | padding-bottom:10px; 636 | } 637 | 638 | 639 | /* Mootools Kwicks 640 | ----------------------------------------------- */ 641 | #kwick-box { 642 | padding:0; 643 | overflow:hidden; 644 | } 645 | #kwick-box h2 { 646 | margin:0; 647 | } 648 | #kwick { 649 | position: relative; 650 | } 651 | #kwick .kwicks { 652 | display: block; 653 | background: #999; 654 | height: 120px; 655 | list-style:none; 656 | margin:0; 657 | overflow:hidden; 658 | } 659 | #kwick li { 660 | float: left; 661 | margin:0; 662 | padding:0; 663 | } 664 | #kwick .kwick { 665 | display: block; 666 | cursor: pointer; 667 | overflow: hidden; 668 | height: 100px; 669 | width: 215px; 670 | padding: 10px; 671 | background: #fff; 672 | } 673 | #kwick .kwick span { 674 | color:#fff; 675 | } 676 | #kwick .one { 677 | background: #666; 678 | } 679 | #kwick .two { 680 | background: #777; 681 | } 682 | #kwick .three { 683 | background: #888; 684 | } 685 | #kwick .four { 686 | background: #999; 687 | } 688 | -------------------------------------------------------------------------------- /css/nav.css: -------------------------------------------------------------------------------- 1 | /* 2 | ----------------------------------------------- 3 | Navigation 4 | ----------------------------------------------- */ 5 | 6 | /* navigation (horizontal subnavigation) 7 | ----------------------------------------------- */ 8 | ul.nav, 9 | ul.nav * { margin:0;padding:0;} 10 | ul.nav { 11 | position:relative; 12 | background:#666; 13 | max-width:100%; 14 | height:2.5em; 15 | } 16 | ul.nav li { 17 | cursor:pointer; 18 | float:left; 19 | text-align:center; 20 | list-style-type:none; 21 | font-weight:normal; 22 | } 23 | ul.nav li ul { 24 | cursor:default; 25 | width:100%; 26 | max-width:100%; 27 | position:absolute; 28 | height:auto; 29 | top:2.5em; 30 | background-position:0 0 !important; 31 | left:-9000px; 32 | } 33 | ul.nav li ul li { 34 | padding:0; 35 | border:none; 36 | width:auto; 37 | max-width:none; 38 | } 39 | ul.nav li a { 40 | color:#fff; 41 | background:#666; 42 | font-weight:bold; 43 | text-decoration:none; 44 | display:block; 45 | float:left; 46 | padding:0 1em; 47 | height:2.4em; 48 | line-height:2.5em; 49 | } 50 | ul.nav li ul li a { 51 | position:relative !important; /* ie Mac */ 52 | cursor:pointer !important; 53 | white-space:nowrap; 54 | line-height:2em; 55 | height:2em; 56 | font-weight:normal; 57 | color:#666; 58 | background-position:0 50% !important; 59 | } 60 | 61 | ul.nav li:hover a, 62 | ul.nav li a:hover, 63 | ul.nav li a:focus {color:#000; background:#ccc;} 64 | ul.nav li a:active {color:#666; background:#fff;} 65 | ul.nav li:hover ul {left:0;z-index:10} 66 | ul.nav li ul, 67 | ul.nav li {background:#ccc !important} 68 | ul.nav li:hover ul li a {color:#444;} 69 | ul.nav li:hover ul li a:hover {color:#000; background:#fff;} 70 | ul.nav li:hover ul li a:active {color:#666; background:#fff;} 71 | 72 | ul.nav li.current a {color:#666; background:#fff; cursor:default; font-weight:bold;} 73 | ul.nav li.current ul {left:0;z-index:5} 74 | ul.nav li.current ul, 75 | ul.nav li.current {background:#ccc !important} 76 | ul.nav li.current ul li a {color:#444; background:#ccc; font-weight:normal;} 77 | ul.nav li.current ul li a:hover {color:#000; background:#fff;} 78 | ul.nav li ul li.current a, 79 | ul.nav li ul li.current a:hover, 80 | ul.nav li.current:hover ul li a:active {color:#666; background:#fff;} 81 | 82 | 83 | /* navigation (vertical subnavigation) 84 | ----------------------------------------------- */ 85 | ul.nav { 86 | background:#666; 87 | } 88 | ul.main li { 89 | position:relative; 90 | top:0; 91 | left:0; 92 | } 93 | ul.main li ul { 94 | border-top:0; 95 | } 96 | ul.main li ul li { 97 | float:left; 98 | } 99 | ul.main li a { 100 | height:2.5em; 101 | line-height:2.5em; 102 | border:0; 103 | color:#fff; 104 | background:#666; 105 | } 106 | ul.main li ul li a { 107 | width:12em; 108 | line-height:2em; 109 | height:2em; 110 | text-align:left; 111 | color:#fff; 112 | border-top:1px solid #444; 113 | background:#444; 114 | } 115 | ul.main li a:focus {color:#fff; background:#666;} 116 | ul.main li ul li a:hover { 117 | color:#fff; 118 | background:#555; 119 | } 120 | ul.main li:hover a { 121 | color:#fff; 122 | background:#555; 123 | } 124 | ul.main li:hover ul li a {color:#fff;} 125 | ul.main li:hover ul li a:hover {color:#fff; background:#444;} 126 | ul.main li:hover a:active {background:#444;} 127 | ul.main li:hover ul li a:active {color:#fff; background:#222;} 128 | 129 | 130 | /* secondary list 131 | ----------------------------------------------- */ 132 | ul.nav li.secondary { 133 | float:right; 134 | color:#cde; 135 | background:transparent !important; 136 | } 137 | ul.nav li.secondary span.status { 138 | float:left; 139 | padding:0 1em; 140 | line-height:2.77em; 141 | height:2.77em; 142 | font-size:0.9em; 143 | } 144 | ul.nav li.secondary span.status a { 145 | float:none; 146 | display:inline; 147 | padding:0; 148 | height:auto; 149 | line-height:auto; 150 | color:#cde; 151 | background:transparent; 152 | } 153 | ul.nav li.secondary span.status a:hover { 154 | color:#fff; 155 | background:transparent; 156 | } 157 | ul.nav li.secondary span.status span { 158 | text-transform:capitalize; 159 | } 160 | ul.nav li.secondary:hover a { 161 | color:#fff; 162 | background:#666; 163 | } 164 | ul.nav li.secondary:hover a:hover { 165 | background:#555; 166 | } 167 | ul.nav li.secondary:hover a:active {background:#444;} 168 | -------------------------------------------------------------------------------- /css/reset.css: -------------------------------------------------------------------------------- 1 | /* http://meyerweb.com/eric/tools/css/reset/ */ 2 | /* v1.0 | 20080212 */ 3 | 4 | html, body, div, span, applet, object, iframe, 5 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 6 | a, abbr, acronym, address, big, cite, code, 7 | del, dfn, em, font, img, ins, kbd, q, s, samp, 8 | small, strike, strong, sub, sup, tt, var, 9 | b, u, i, center, 10 | dl, dt, dd, ol, ul, li, 11 | fieldset, form, label, legend, 12 | table, caption, tbody, tfoot, thead, tr, th, td { 13 | margin: 0; 14 | padding: 0; 15 | border: 0; 16 | outline: 0; 17 | font-size: 100%; 18 | vertical-align: baseline; 19 | background: transparent; 20 | } 21 | body { 22 | line-height: 1; 23 | } 24 | ol, ul { 25 | list-style: none; 26 | } 27 | blockquote, q { 28 | quotes: none; 29 | } 30 | blockquote:before, blockquote:after, 31 | q:before, q:after { 32 | content: ''; 33 | content: none; 34 | } 35 | 36 | /* remember to define focus styles! */ 37 | :focus { 38 | outline: 0; 39 | } 40 | 41 | /* remember to highlight inserts somehow! */ 42 | ins { 43 | text-decoration: none; 44 | } 45 | del { 46 | text-decoration: line-through; 47 | } 48 | 49 | /* tables still need 'cellspacing="0"' in the markup */ 50 | table { 51 | border-collapse: collapse; 52 | border-spacing: 0; 53 | } -------------------------------------------------------------------------------- /css/text.css: -------------------------------------------------------------------------------- 1 | /* 2 | 960 Grid System ~ Text CSS. 3 | Learn more ~ http://960.gs/ 4 | 5 | Licensed under GPL and MIT. 6 | */ 7 | 8 | /* =Basic HTML 9 | --------------------------------------------------------------------------------*/ 10 | 11 | body 12 | { 13 | font: 13px/1.5 Helvetica, Arial, 'Liberation Sans', FreeSans, sans-serif; 14 | } 15 | 16 | a:focus 17 | { 18 | outline: 1px dotted invert; 19 | } 20 | 21 | hr 22 | { 23 | border-color: #ccc; 24 | border-style: solid; 25 | border-width: 1px 0 0; 26 | clear: both; 27 | height: 0; 28 | } 29 | 30 | /* =Headings 31 | --------------------------------------------------------------------------------*/ 32 | 33 | h1 34 | { 35 | font-size: 25px; 36 | } 37 | 38 | h2 39 | { 40 | font-size: 23px; 41 | } 42 | 43 | h3 44 | { 45 | font-size: 21px; 46 | } 47 | 48 | h4 49 | { 50 | font-size: 19px; 51 | } 52 | 53 | h5 54 | { 55 | font-size: 17px; 56 | } 57 | 58 | h6 59 | { 60 | font-size: 15px; 61 | } 62 | 63 | /* =Spacing 64 | --------------------------------------------------------------------------------*/ 65 | 66 | ol 67 | { 68 | list-style: decimal; 69 | } 70 | 71 | ul 72 | { 73 | list-style: square; 74 | } 75 | 76 | li 77 | { 78 | margin-left: 30px; 79 | } 80 | 81 | p, 82 | dl, 83 | hr, 84 | h1, 85 | h2, 86 | h3, 87 | h4, 88 | h5, 89 | h6, 90 | ol, 91 | ul, 92 | pre, 93 | table, 94 | address, 95 | fieldset 96 | { 97 | margin-bottom: 20px; 98 | } -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/git/git-reference/0de29ad3af4e179ddf8465c1ae6c28d5fca42167/favicon.ico -------------------------------------------------------------------------------- /favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/git/git-reference/0de29ad3af4e179ddf8465c1ae6c28d5fca42167/favicon.png -------------------------------------------------------------------------------- /images/snapshots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/git/git-reference/0de29ad3af4e179ddf8465c1ae6c28d5fca42167/images/snapshots.png -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: reference 3 | --- 4 |
5 |

Introduction to the Git Reference

6 |
7 |

8 | This is the Git reference site. It is meant to be a quick 9 | reference for learning and remembering the most important and 10 | commonly used Git commands. The commands are organized into 11 | sections of the type of operation you may be trying to do, and 12 | will present the common options and commands needed to accomplish 13 | these common tasks. 14 |

15 |

16 | Each section will link to the next section, so it can be used 17 | as a tutorial. Every page will also link to more in-depth 18 | Git documentation such as the official manual pages and relevant 19 | sections in the Pro Git book, 20 | so you can learn more about any of 21 | the commands. First, we'll start with thinking about source code 22 | management like Git does. 23 |

24 |
25 |
26 | 27 |
28 |

How to Think Like Git

29 |
30 |

31 | The first important thing to understand about Git is 32 | that it thinks about version control very differently than 33 | Subversion or Perforce or whatever SCM you may be used to. It 34 | is often easier to learn Git by trying to forget your assumptions 35 | about how version control works and try to think about it in the 36 | Git way. 37 |

38 | 39 |

40 | Let's start from scratch. Assume you are designing a new source 41 | code management system. How did you do basic version control before 42 | you used a tool for it? Chances are that you simply copied your 43 | project directory to save what it looked like at that point. 44 |

45 | 46 |
 $ cp -R project project.bak 
47 | 48 |

49 | That way, you can easily revert files that get messed up later, or 50 | see what you have changed by comparing what the project looks like 51 | now to what it looked like when you copied it. 52 |

53 | 54 |

55 | If you are really paranoid, you may do this often, maybe putting the 56 | date in the name of the backup: 57 |

58 | 59 |
 $ cp -R project project.2010-06-01.bak 
60 | 61 |

62 | In that case, you may have a bunch of snapshots of your project that 63 | you can compare and inspect from. You can even use this model to 64 | fairly effectively share changes with someone. If you zip up your 65 | project at a known state and put it on your website, other developers 66 | can download that, change it and send you a patch pretty easily. 67 |

68 | 69 |
 70 |  $ wget http://example.com/project.2010-06-01.zip
 71 |  $ unzip project.2010-06-01.zip
 72 |  $ cp -R project.2010-06-01 project-my-copy
 73 |  $ cd project-my-copy
 74 |  $ (change something)
 75 |  $ diff project-my-copy project.2010-06-01 > change.patch
 76 |  $ (email change.patch)
77 | 78 |

79 | Now the original developer can apply that patch to their copy of the 80 | project and they have your changes. This is how many open source 81 | projects have been collaborated on for several years. 82 |

83 | 84 |

85 | This actually works fairly well, so let's say we want to write a tool 86 | to make this basic process faster and easier. Instead of writing a tool 87 | that versions each file individually, like Subversion, we would probably 88 | write one that makes it easier to store snapshots of our project without 89 | having to copy the whole directory each time. 90 |

91 | 92 |

93 | This is essentially what Git is. You tell Git you want to save a snapshot 94 | of your project with the git commit command and it basically 95 | records a manifest of what all of the files in your project look like at 96 | that point. Then most of the commands work with those manifests to see 97 | how they differ or pull content out of them, etc. 98 |

99 | 100 |
101 | 102 |

103 | If you think about Git 104 | as a tool for storing and comparing and merging snapshots of your project, 105 | it may be easier to understand what is going on and how to do things 106 | properly. 107 |

108 | 109 |
110 |
111 | 112 |

On to Getting and Creating Projects »

113 | -------------------------------------------------------------------------------- /inspect/index.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: reference 3 | --- 4 | 5 |
6 |

7 | 8 | book 9 | 10 | Inspection and Comparison 11 |

12 |
13 |

14 | So now you have a bunch of branches that you are using for short lived 15 | topics, long lived features and what not. How do you keep track of them? 16 | Git has a couple of tools to help you figure out where work was done, what 17 | the difference between two branches are and more. 18 |

19 | 20 |

21 | In a nutshell you can use git log to find specific 22 | commits in your project history - by author, date, content or 23 | history. You can use git diff to compare two different points 24 | in your history - generally to see how two branches differ or what has 25 | changed from one version of your software to another. 26 |

27 |
28 |
29 | 30 |
31 |

32 | 33 | docs   34 | book 35 | 36 | git log 37 | filter your commit history 38 |

39 | 40 |
41 |

We've already seen how to use git log to compare branches, 42 | by looking at the commits on one branch that are not reachable from another. 43 | (If you don't remember, it looks like this: git log branchA ^branchB). 44 | However, you can also use git log to look for specific commits. 45 | Here we'll be looking at some of the more commonly used git log 46 | options, but there are many. Take a look at the official docs for the whole 47 | list. 48 |

49 | 50 |

51 | git log --author 52 | look for only commits from a specific author 53 |

54 | 55 |

56 | To filter your commit history to only the ones done by a specific author, 57 | you can use the --author option. For example, let's say we're 58 | looking for the commits in the Git source code done by Linus. We would 59 | type something like git log --author=Linus. The search is 60 | case sensitive and will also search the email address. The following 61 | example will use the -[number] option, which will limit the 62 | results to the last [number] commits. 63 |

64 | 65 |
 66 | $ git log --author=Linus --oneline -5
 67 | 81b50f3 Move 'builtin-*' into a 'builtin/' subdirectory
 68 | 3bb7256 make "index-pack" a built-in
 69 | 377d027 make "git pack-redundant" a built-in
 70 | b532581 make "git unpack-file" a built-in
 71 | 112dd51 make "mktag" a built-in
 72 | 
73 | 74 |

75 | git log --since --before 76 | filter commits by date committed 77 |

78 | 79 |

80 | If you want to specify a date range that you're interested in filtering your 81 | commits down to, you can use a number of options such as --since 82 | and --before, or you can also use --until and 83 | --after. For example, to see all the commits in 84 | the Git project before three weeks ago but after April 18th, you could run this 85 | (We're also going to use --no-merges to remove merge commits): 86 |

87 | 88 |
 89 | $ git log --oneline --before={3.weeks.ago} --after={2010-04-18} --no-merges
 90 | 5469e2d Git 1.7.1-rc2
 91 | d43427d Documentation/remote-helpers: Fix typos and improve language
 92 | 272a36b Fixup: Second argument may be any arbitrary string
 93 | b6c8d2d Documentation/remote-helpers: Add invocation section
 94 | 5ce4f4e Documentation/urls: Rewrite to accomodate transport::address
 95 | 00b84e9 Documentation/remote-helpers: Rewrite description
 96 | 03aa87e Documentation: Describe other situations where -z affects git diff
 97 | 77bc694 rebase-interactive: silence warning when no commits rewritten
 98 | 636db2c t3301: add tests to use --format="%N"
 99 | 
100 | 101 |

102 | git log --grep 103 | filter commits by commit message 104 |

105 | 106 |

107 | You may also want to look for commits with a certain phrase in the commit 108 | message. Use --grep for that. Let's say there 109 | was a commit that dealt with using the P4EDITOR environment variable and 110 | you wanted to remember what that change looked like - you could find the commit 111 | with --grep. 112 |

113 | 114 |
115 | $ git log --grep=P4EDITOR --no-merges
116 | commit 82cea9ffb1c4677155e3e2996d76542502611370
117 | Author: Shawn Bohrer
118 | Date:   Wed Mar 12 19:03:24 2008 -0500
119 | 
120 |     git-p4: Use P4EDITOR environment variable when set
121 | 
122 |     Perforce allows you to set the P4EDITOR environment variable to your
123 |     preferred editor for use in perforce.  Since we are displaying a
124 |     perforce changelog to the user we should use it when it is defined.
125 | 
126 |     Signed-off-by: Shawn Bohrer <shawn.bohrer@gmail.com>
127 |     Signed-off-by: Simon Hausmann <simon@lst.de>
128 | 
129 | 130 |

131 | Git will logically OR all --grep and --author 132 | arguments. If you want to use --grep and --author 133 | to see commits that were authored by someone AND have a specific message 134 | content, you have to add the --all-match option. In these 135 | examples we're going to use the --format option, so we can see 136 | who the author of each commit was. 137 |

138 | 139 |

If we look for the commit messages with 'p4 depo' in them, we get these 140 | three commits:

141 | 142 |
143 | $ git log --grep="p4 depo" --format="%h %an %s"
144 | ee4fd1a Junio C Hamano Merge branch 'master' of git://repo.or.cz/git/fastimport
145 | da4a660 Benjamin Sergeant git-p4 fails when cloning a p4 depo.
146 | 1cd5738 Simon Hausmann Make incremental imports easier to use by storing the p4 d
147 | 
148 | 149 |

If we add a --author=Hausmann argument, instead of further 150 | filtering it down to the one commit by Simon, it instead will show all 151 | commits by Simon OR commits with "p4 depo" in the message:

152 | 153 |
154 | $ git log --grep="p4 depo" --format="%h %an %s" --author="Hausmann"
155 | cdc7e38 Simon Hausmann Make it possible to abort the submission of a change to Pe
156 | f5f7e4a Simon Hausmann Clean up the git-p4 documentation
157 | 30b5940 Simon Hausmann git-p4: Fix import of changesets with file deletions
158 | 4c750c0 Simon Hausmann git-p4: git-p4 submit cleanups.
159 | 0e36f2d Simon Hausmann git-p4: Removed git-p4 submit --direct.
160 | edae1e2 Simon Hausmann git-p4: Clean up git-p4 submit's log message handling.
161 | 4b61b5c Simon Hausmann git-p4: Remove --log-substitutions feature.
162 | 36ee4ee Simon Hausmann git-p4: Ensure the working directory and the index are cle
163 | e96e400 Simon Hausmann git-p4: Fix submit user-interface.
164 | 38f9f5e Simon Hausmann git-p4: Fix direct import from perforce after fetching cha
165 | 2094714 Simon Hausmann git-p4: When skipping a patch as part of "git-p4 submit" m
166 | 1ca3d71 Simon Hausmann git-p4: Added support for automatically importing newly ap
167 | ...
168 | 
169 | 170 |

However, adding --all-match will get the results you're 171 | looking for:

172 | 173 |
174 | $ git log --grep="p4 depo" --format="%h %an %s" --author="Hausmann" --all-match
175 | 1cd5738 Simon Hausmann Make incremental imports easier to use by storing the p4 d
176 | 
177 | 178 |

179 | git log -S 180 | filter by introduced diff 181 |

182 | 183 |

184 | What if you write really horrible commit messages? Or, what if you are 185 | looking for when a function was introduced, or where variables started 186 | to be used? You can also tell Git to look through the diff of each 187 | commit for a string. For example, if we wanted to find which commits 188 | modified anything that looked like the function name 189 | 'userformat_find_requirements', we would run this: (note there is no '=' 190 | between the '-S' and what you are searching for) 191 |

192 | 193 |
194 | $ git log -Suserformat_find_requirements
195 | commit 5b16360330822527eac1fa84131d185ff784c9fb
196 | Author: Johannes Gilger
197 | Date:   Tue Apr 13 22:31:12 2010 +0200
198 | 
199 |     pretty: Initialize notes if %N is used
200 | 
201 |     When using git log --pretty='%N' without an explicit --show-notes, git
202 |     would segfault. This patches fixes this behaviour by loading the needed
203 |     notes datastructures if --pretty is used and the format contains %N.
204 |     When --pretty='%N' is used together with --no-notes, %N won't be
205 |     expanded.
206 | 
207 |     This is an extension to a proposed patch by Jeff King.
208 | 
209 |     Signed-off-by: Johannes Gilger
210 |     Signed-off-by: Junio C Hamano
211 | 
212 | 213 |

214 | git log -p 215 | show patch introduced at each commit 216 |

217 | 218 |

219 | Each commit is a snapshot of the project, but since each commit records the 220 | snapshot it was based off of, Git can always calculate the difference and 221 | show it to you as a patch. That means for any commit you can get the patch 222 | that commit introduced to the project. You can either do this by running 223 | git show [SHA] with a specific commit SHA, or you can run 224 | git log -p, which tells Git to put the patch after each commit. 225 | It is a great way to summarize what has happened on a branch or between 226 | commits. 227 |

228 | 229 |
230 | $ git log -p --no-merges -2
231 | commit 594f90bdee4faf063ad07a4a6f503fdead3ef606
232 | Author: Scott Chacon <schacon@gmail.com>
233 | Date:   Fri Jun 4 15:46:55 2010 +0200
234 | 
235 |     reverted to old class name
236 | 
237 | diff --git a/ruby.rb b/ruby.rb
238 | index bb86f00..192151c 100644
239 | --- a/ruby.rb
240 | +++ b/ruby.rb
241 | @@ -1,7 +1,7 @@
242 | -class HiWorld
243 | +class HelloWorld
244 |    def self.hello
245 |      puts "Hello World from Ruby"
246 |    end
247 |  end
248 | 
249 | -HiWorld.hello
250 | +HelloWorld.hello
251 | 
252 | commit 3cbb6aae5c0cbd711c098e113ae436801371c95e
253 | Author: Scott Chacon <schacon@gmail.com>
254 | Date:   Fri Jun 4 12:58:53 2010 +0200
255 | 
256 |     fixed readme title differently
257 | 
258 | diff --git a/README b/README
259 | index d053cc8..9103e27 100644
260 | --- a/README
261 | +++ b/README
262 | @@ -1,4 +1,4 @@
263 | -Hello World Examples
264 | +Many Hello World Examples
265 |  ======================
266 | 
267 |  This project has examples of hello world in
268 | 
269 | 270 |

This is a really nice way of summarizing changes or reviewing a series 271 | of commits before merging them or releasing something.

272 | 273 |

274 | git log --stat 275 | show diffstat of changes introduced at each commit 276 |

277 | 278 |

If the -p option is too verbose for you, you can summarize 279 | the changes with --stat instead. Here is the same log output 280 | with --stat instead of -p

281 | 282 |
283 | $ git log --stat --no-merges -2
284 | commit 594f90bdee4faf063ad07a4a6f503fdead3ef606
285 | Author: Scott Chacon <schacon@gmail.com>
286 | Date:   Fri Jun 4 15:46:55 2010 +0200
287 | 
288 |     reverted to old class name
289 | 
290 |  ruby.rb |    4 ++--
291 |  1 files changed, 2 insertions(+), 2 deletions(-)
292 | 
293 | commit 3cbb6aae5c0cbd711c098e113ae436801371c95e
294 | Author: Scott Chacon <schacon@gmail.com>
295 | Date:   Fri Jun 4 12:58:53 2010 +0200
296 | 
297 |     fixed readme title differently
298 | 
299 |  README |    2 +-
300 |  1 files changed, 1 insertions(+), 1 deletions(-)
301 | 
302 | 303 |

Same basic information, but a little more compact - it still lets you 304 | see relative changes and which files were modified.

305 | 306 |
307 |
308 | 309 |
310 |

311 | 312 | docs   313 | book 314 | 315 | git diff 316 | 317 |

318 | 319 |
320 | 321 |

Finally, to see the absolute changes between any two commit snapshots, 322 | you can use the git diff command. This is largely used in two 323 | main situations - seeing how two branches differ from one another and 324 | seeing what has changed since a release or some other older point in 325 | history. Let's look at both of these situations.

326 | 327 |

To see what has changed since the last release, you can simply run 328 | git diff [version] (or whatever you tagged the release). 329 | For example, if we want to see what has changed in our project since 330 | the v0.9 release, we can run git diff v0.9. 331 |

332 | 333 |
334 | $ git diff v0.9
335 | diff --git a/README b/README
336 | index d053cc8..d4173d5 100644
337 | --- a/README
338 | +++ b/README
339 | @@ -1,4 +1,4 @@
340 | -Hello World Examples
341 | +Many Hello World Lang Examples
342 |  ======================
343 | 
344 |  This project has examples of hello world in
345 | diff --git a/ruby.rb b/ruby.rb
346 | index bb86f00..192151c 100644
347 | --- a/ruby.rb
348 | +++ b/ruby.rb
349 | @@ -1,7 +1,7 @@
350 | -class HiWorld
351 | +class HelloWorld
352 |    def self.hello
353 |      puts "Hello World from Ruby"
354 |    end
355 |  end
356 | 
357 | -HiWorld.hello
358 | +HelloWorld.hello
359 | 
360 | 361 |

Just like git log, you can use the --stat 362 | option with it.

363 | 364 |
365 | $ git diff v0.9 --stat
366 |  README  |    2 +-
367 |  ruby.rb |    4 ++--
368 |  2 files changed, 3 insertions(+), 3 deletions(-)
369 | 
370 | 371 |

To compare two divergent branches, however, you can run something like 372 | git diff branchA branchB but the problem is that it will do 373 | exactly what you are asking - it will basically give you a patch file that 374 | would turn the snapshot at the tip of branchA into the snapshot at the tip 375 | of branchB. This means if the two branches have diverged - gone in different 376 | directions - it will remove all the work that was introduced into branchA 377 | and then add everything that was introduced into branchB. This is probably 378 | not what you want - you want the changes added to branchB that are not in 379 | branchA, so you really want the difference between where the two branches 380 | diverged and the tip of branchB. So, if our history looks like this:

381 | 382 |
383 | $ git log --graph --oneline --decorate --all
384 | * 594f90b (HEAD, tag: v1.0, master) reverted to old class name
385 | | * 1834130 (erlang) added haskell
386 | | * ab5ab4c added erlang
387 | |/
388 | *   8d585ea Merge branch 'fix_readme'
389 | ...
390 | 
391 | 392 |

And we want to see what is on the "erlang" branch compared to the "master" 393 | branch, running git diff master erlang will give us the wrong 394 | thing.

395 | 396 |
397 | $ git diff --stat master erlang
398 |  erlang_hw.erl |    5 +++++
399 |  haskell.hs    |    4 ++++
400 |  ruby.rb       |    4 ++--
401 |  3 files changed, 11 insertions(+), 2 deletions(-)
402 | 
403 | 404 |

You see that it adds the erlang and haskell files, which is what we did 405 | in that branch, but then the output also reverts the changes to the ruby file 406 | that we did in the master branch. What we really want to see is just the 407 | changes that happened in the "erlang" branch (adding the two files). We can 408 | get the desired result by doing the diff from the common commit they diverged 409 | from:

410 | 411 |
412 | $ git diff --stat 8d585ea erlang
413 |  erlang_hw.erl |    5 +++++
414 |  haskell.hs    |    4 ++++
415 |  2 files changed, 9 insertions(+), 0 deletions(-)
416 | 
417 | 418 |

That's what we're looking for, but we don't want to have to figure out 419 | what commit the two branches diverged from every time. Luckily, Git has a 420 | shortcut for this. If you run git diff master...erlang (with 421 | three dots in between the branch names), Git will automatically figure out 422 | what the common commit (otherwise known as the "merge base") of the two 423 | commit is and do the diff off of that.

424 | 425 |
426 | $ git diff --stat master erlang
427 |  erlang_hw.erl |    5 +++++
428 |  haskell.hs    |    4 ++++
429 |  ruby.rb       |    4 ++--
430 |  3 files changed, 11 insertions(+), 2 deletions(-)
431 | $ git diff --stat master...erlang
432 |  erlang_hw.erl |    5 +++++
433 |  haskell.hs    |    4 ++++
434 |  2 files changed, 9 insertions(+), 0 deletions(-)
435 | 
436 | 437 |

Nearly every time you want to compare two branches, you'll want to use 438 | the triple-dot syntax, because it will almost always give you what you want. 439 |

440 | 441 |

As a bit of an aside, you can also have Git manually calculate what the 442 | merge-base (first common ancestor commit) of any two commits would be with 443 | the git merge-base command:

444 | 445 |
446 | $ git merge-base master erlang
447 | 8d585ea6faf99facd39b55d6f6a3b3f481ad0d3d
448 | 
449 | 450 |

You can do the equivalent of git diff master...erlang 451 | by running this:

452 | 453 |
454 | $ git diff --stat $(git merge-base master erlang) erlang
455 |  erlang_hw.erl |    5 +++++
456 |  haskell.hs    |    4 ++++
457 |  2 files changed, 9 insertions(+), 0 deletions(-)
458 | 
459 | 460 |

You may prefer using the easier syntax though.

461 | 462 | 463 |

464 | In a nutshell you can use git diff to see how a project 465 | has changed since a known point in the past or to see what unique work is 466 | in one branch since it diverged from another. Always use 467 | git diff branchA...branchB to inspect branchB relative to 468 | branchA to make things easier. 469 |

470 | 471 |
472 |
473 | 474 |

And that's it! For more information, try reading the 475 | Pro Git book.

476 | -------------------------------------------------------------------------------- /js/action.js: -------------------------------------------------------------------------------- 1 | jQuery.githubUser = function(username, callback) { 2 | jQuery.getJSON("http://github.com/api/v1/json/" + username + "?callback=?", callback); 3 | } 4 | 5 | var nicknames = ["Dragon", "Gizzard", "The Enforcer", 6 | "Mizungu", "The Hammer"] 7 | var phrases = ["also feels that specialization is for insects", 8 | "my dogs named tater tooooo", 9 | "every movie should have a cast dance scene at the end", 10 | "honey, you're a tool of the masses", 11 | "my life is kinda like the Matrix, really", 12 | "too fat to fit into Japanese pants", 13 | "it's like the finger of God!"] 14 | function changeBlurb() { 15 | var phrase = phrases[Math.floor(Math.random()*phrases.length)] 16 | $('#page-heading').text(phrase) 17 | t=setTimeout("changeBlurb()",30000); 18 | } 19 | 20 | function changeNickname() { 21 | var nickname = nicknames[Math.floor(Math.random()*nicknames.length)] 22 | $('#nickname').text(nickname) 23 | t=setTimeout("changeNickname()",30000); 24 | } 25 | 26 | function showHome() { 27 | $('#break').show() 28 | $('.non_home_box').hide('scale') 29 | $('.home_box').show('scale') 30 | } 31 | 32 | function showTalks() { 33 | $('#break').hide() 34 | $('#info_box').show() 35 | $("#info_box").load("talks.html", null, function() { 36 | window.location.hash = 'talks' 37 | }); 38 | } 39 | 40 | function showScribbles() { 41 | $('#break').hide() 42 | $('#info_box').show() 43 | $("#info_box").load("scribbles.html", null, function() { 44 | window.location.hash = 'scribbles' 45 | }); 46 | } 47 | 48 | function showAbout() { 49 | $('#break').hide() 50 | $('#info_box').show() 51 | $("#info_box").load("about.html", null, function() { 52 | window.location.hash = 'about' 53 | $("a#menu_talks").click(function(event){ 54 | hideAll() 55 | showTalks() 56 | }) 57 | }); 58 | } 59 | 60 | function showCode() { 61 | $('#break').hide() 62 | $('#info_box').show() 63 | $("#info_box").load("code.html", null, function() { 64 | $.githubUser('schacon', function(data) { 65 | $('#github-projects').text('') 66 | var repos = data.user.repositories; 67 | repos.sort(function(a,b) { 68 | return b.watchers - a.watchers; 69 | }); 70 | 71 | $(repos).each(function() { 72 | if((!this.fork) && (!this.private)) { 73 | $('#github-projects').append("\ 74 |
\ 75 |

" + this.name + "

\ 76 | "+this.description+"\ 77 | " + this.watchers + " \ 78 | " + this.forks + "\ 79 |
"); 80 | } 81 | }); 82 | }); 83 | window.location.hash = 'code' 84 | }); 85 | } 86 | 87 | function hideAll() { 88 | $('.non_home_box').hide() 89 | $('.home_box').hide() 90 | } 91 | 92 | $(document).ready(function(){ 93 | changeBlurb() 94 | changeNickname() 95 | if(window.location.hash != "") { 96 | page = window.location.hash 97 | if(page == '#talks') { 98 | hideAll() 99 | showTalks() 100 | } 101 | if(page == '#code') { 102 | hideAll() 103 | showCode() 104 | } 105 | if(page == '#about') { 106 | hideAll() 107 | showAbout() 108 | } 109 | if(page == '#scribbles') { 110 | hideAll() 111 | showScribbles() 112 | } 113 | } 114 | 115 | $("a#menu_home").click(function(event){ 116 | showHome() 117 | }) 118 | 119 | $("a#menu_talks").click(function(event){ 120 | hideAll() 121 | showTalks() 122 | }) 123 | 124 | $("a#menu_code").click(function(event){ 125 | hideAll() 126 | showCode() 127 | }) 128 | 129 | $("a#menu_about").click(function(event){ 130 | hideAll() 131 | showAbout() 132 | }) 133 | 134 | $("a#menu_scribbles").click(function(event){ 135 | hideAll() 136 | showScribbles() 137 | }) 138 | 139 | }) 140 | -------------------------------------------------------------------------------- /js/jquery-ui.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery UI 1.8rc1 3 | * 4 | * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) 5 | * Dual licensed under the MIT (MIT-LICENSE.txt) 6 | * and GPL (GPL-LICENSE.txt) licenses. 7 | * 8 | * http://docs.jquery.com/UI 9 | */ /* 10 | * jQuery UI 1.8rc1 11 | * 12 | * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) 13 | * Dual licensed under the MIT (MIT-LICENSE.txt) 14 | * and GPL (GPL-LICENSE.txt) licenses. 15 | * 16 | * http://docs.jquery.com/UI 17 | */ 18 | jQuery.ui||(function(b){var a=b.browser.mozilla&&(parseFloat(b.browser.version)<1.9);b.ui={version:"1.8rc1",plugin:{add:function(d,e,g){var f=b.ui[d].prototype;for(var c in g){f.plugins[c]=f.plugins[c]||[];f.plugins[c].push([e,g[c]])}},call:function(c,e,d){var g=c.plugins[e];if(!g||!c.element[0].parentNode){return}for(var f=0;f0){return true}f[c]=1;e=(f[c]>0);f[c]=0;return e},isOverAxis:function(d,c,e){return(d>c)&&(d<(c+e))},isOver:function(h,d,g,f,c,e){return b.ui.isOverAxis(h,g,c)&&b.ui.isOverAxis(d,f,e)},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};b.fn.extend({_focus:b.fn.focus,focus:function(c,d){return typeof c==="number"?this.each(function(){var e=this;setTimeout(function(){b(e).focus();(d&&d.call(e))},c)}):this._focus.apply(this,arguments)},enableSelection:function(){return this.attr("unselectable","off").css("MozUserSelect","").unbind("selectstart.ui")},disableSelection:function(){return this.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})},scrollParent:function(){var c;if((b.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){c=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test(b.curCSS(this,"position",1))&&(/(auto|scroll)/).test(b.curCSS(this,"overflow",1)+b.curCSS(this,"overflow-y",1)+b.curCSS(this,"overflow-x",1))}).eq(0)}else{c=this.parents().filter(function(){return(/(auto|scroll)/).test(b.curCSS(this,"overflow",1)+b.curCSS(this,"overflow-y",1)+b.curCSS(this,"overflow-x",1))}).eq(0)}return(/fixed/).test(this.css("position"))||!c.length?b(document):c},zIndex:function(d){if(d!==undefined){return this.css("zIndex",d)}var c=this[0];while(c&&c.style){if(c.style.zIndex!==""&&c.style.zIndex!==0){return +c.style.zIndex}c=c.parentNode}return 0}});b.extend(b.expr[":"],{data:function(e,d,c){return !!b.data(e,c[3])},focusable:function(d){var e=d.nodeName.toLowerCase(),c=b.attr(d,"tabindex");return(/input|select|textarea|button|object/.test(e)?!d.disabled:"a"==e||"area"==e?d.href||!isNaN(c):!isNaN(c))&&!b(d)["area"==e?"parents":"closest"](":hidden").length},tabbable:function(d){var c=b.attr(d,"tabindex");return(isNaN(c)||c>=0)&&b(d).is(":focusable")}})})(jQuery);;/*! 19 | * jQuery UI Widget 1.8rc1 20 | * 21 | * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) 22 | * Dual licensed under the MIT (MIT-LICENSE.txt) 23 | * and GPL (GPL-LICENSE.txt) licenses. 24 | * 25 | * http://docs.jquery.com/UI/Widget 26 | */ /* 27 | * jQuery UI Widget 1.8rc1 28 | * 29 | * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) 30 | * Dual licensed under the MIT (MIT-LICENSE.txt) 31 | * and GPL (GPL-LICENSE.txt) licenses. 32 | * 33 | * http://docs.jquery.com/UI/Widget 34 | */ 35 | (function(b){var a=b.fn.remove;b.fn.remove=function(c,d){if(!d){b("*",this).add(this).each(function(){b(this).triggerHandler("remove")})}return a.apply(this,arguments)};b.widget=function(d,f,c){var e=d.split(".")[0],h;d=d.split(".")[1];h=e+"-"+d;if(!c){c=f;f=b.Widget}b.expr[":"][h]=function(i){return !!b.data(i,d)};b[e]=b[e]||{};b[e][d]=function(i,j){if(arguments.length){this._createWidget(i,j)}};var g=new f();g.options=b.extend({},g.options);b[e][d].prototype=b.extend(true,g,{namespace:e,widgetName:d,widgetEventPrefix:b[e][d].prototype.widgetEventPrefix||d,widgetBaseClass:h},c);b.widget.bridge(d,b[e][d])};b.widget.bridge=function(d,c){b.fn[d]=function(g){var e=typeof g==="string",f=Array.prototype.slice.call(arguments,1),h=this;g=!e&&f.length?b.extend.apply(null,[true,g].concat(f)):g;if(e&&g.substring(0,1)==="_"){return h}if(e){this.each(function(){var i=b.data(this,d),j=i&&b.isFunction(i[g])?i[g].apply(i,f):i;if(j!==i&&j!==undefined){h=j;return false}})}else{this.each(function(){var i=b.data(this,d);if(i){if(g){i.option(g)}i._init()}else{b.data(this,d,new c(g,this))}})}return h}};b.Widget=function(c,d){if(arguments.length){this._createWidget(c,d)}};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(d,e){this.element=b(e).data(this.widgetName,this);this.options=b.extend(true,{},this.options,b.metadata&&b.metadata.get(e)[this.widgetName],d);var c=this;this.element.bind("remove."+this.widgetName,function(){c.destroy()});this._create();this._init()},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled")},widget:function(){return this.element},option:function(e,f){var d=e,c=this;if(arguments.length===0){return b.extend({},c.options)}if(typeof e==="string"){if(f===undefined){return this.options[e]}d={};d[e]=f}b.each(d,function(g,h){c._setOption(g,h)});return c},_setOption:function(c,d){this.options[c]=d;if(c==="disabled"){this.widget()[d?"addClass":"removeClass"](this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").attr("aria-disabled",d)}return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(d,e,f){var h=this.options[d];e=b.Event(e);e.type=(d===this.widgetEventPrefix?d:this.widgetEventPrefix+d).toLowerCase();f=f||{};if(e.originalEvent){for(var c=b.event.props.length,g;c;){g=b.event.props[--c];e[g]=e.originalEvent[g]}}this.element.trigger(e,f);return !(b.isFunction(h)&&h.call(this.element[0],e,f)===false||e.isDefaultPrevented())}}})(jQuery);;/*! 36 | * jQuery UI Mouse 1.8rc1 37 | * 38 | * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) 39 | * Dual licensed under the MIT (MIT-LICENSE.txt) 40 | * and GPL (GPL-LICENSE.txt) licenses. 41 | * 42 | * http://docs.jquery.com/UI/Mouse 43 | * 44 | * Depends: 45 | * jquery.ui.widget.js 46 | */ /* 47 | * jQuery UI Mouse 1.8rc1 48 | * 49 | * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) 50 | * Dual licensed under the MIT (MIT-LICENSE.txt) 51 | * and GPL (GPL-LICENSE.txt) licenses. 52 | * 53 | * http://docs.jquery.com/UI/Mouse 54 | * 55 | * Depends: 56 | * jquery.ui.widget.js 57 | */ 58 | (function(a){a.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var b=this;this.element.bind("mousedown."+this.widgetName,function(c){return b._mouseDown(c)}).bind("click."+this.widgetName,function(c){if(b._preventClickEvent){b._preventClickEvent=false;c.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(d){d.originalEvent=d.originalEvent||{};if(d.originalEvent.mouseHandled){return}(this._mouseStarted&&this._mouseUp(d));this._mouseDownEvent=d;var c=this,e=(d.which==1),b=(typeof this.options.cancel=="string"?a(d.target).parents().add(d.target).filter(this.options.cancel).length:false);if(!e||b||!this._mouseCapture(d)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){c.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(d)&&this._mouseDelayMet(d)){this._mouseStarted=(this._mouseStart(d)!==false);if(!this._mouseStarted){d.preventDefault();return true}}this._mouseMoveDelegate=function(f){return c._mouseMove(f)};this._mouseUpDelegate=function(f){return c._mouseUp(f)};a(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);(a.browser.safari||d.preventDefault());d.originalEvent.mouseHandled=true;return true},_mouseMove:function(b){if(a.browser.msie&&!b.button){return this._mouseUp(b)}if(this._mouseStarted){this._mouseDrag(b);return b.preventDefault()}if(this._mouseDistanceMet(b)&&this._mouseDelayMet(b)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,b)!==false);(this._mouseStarted?this._mouseDrag(b):this._mouseUp(b))}return !this._mouseStarted},_mouseUp:function(b){a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(b.target==this._mouseDownEvent.target);this._mouseStop(b)}return false},_mouseDistanceMet:function(b){return(Math.max(Math.abs(this._mouseDownEvent.pageX-b.pageX),Math.abs(this._mouseDownEvent.pageY-b.pageY))>=this.options.distance)},_mouseDelayMet:function(b){return this.mouseDelayMet},_mouseStart:function(b){},_mouseDrag:function(b){},_mouseStop:function(b){},_mouseCapture:function(b){return true}})})(jQuery);;/* 59 | * jQuery UI Position 1.8rc1 60 | * 61 | * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) 62 | * Dual licensed under the MIT (MIT-LICENSE.txt) 63 | * and GPL (GPL-LICENSE.txt) licenses. 64 | * 65 | * http://docs.jquery.com/UI/Position 66 | */ (function(f){f.ui=f.ui||{};var c=/left|center|right/,e="center",d=/top|center|bottom/,g="center",a=f.fn.position;f.fn.position=function(i){if(!i||!i.of){return a.apply(this,arguments)}i=f.extend({},i);var l=f(i.of),n=(i.collision||"flip").split(" "),m=i.offset?i.offset.split(" "):[0,0],k,h,j;if(i.of.nodeType===9){k=l.width();h=l.height();j={top:0,left:0}}else{if(i.of.scrollTo&&i.of.document){k=l.width();h=l.height();j={top:l.scrollTop(),left:l.scrollLeft()}}else{if(i.of.preventDefault){i.at="left top";k=h=0;j={top:i.of.pageY,left:i.of.pageX}}else{k=l.outerWidth();h=l.outerHeight();j=l.offset()}}}f.each(["my","at"],function(){var o=(i[this]||"").split(" ");o=o.length==1?c.test(o[0])?o.concat([g]):d.test(o[0])?[e].concat(o):[e,g]:o;o[0]=c.test(o[0])?o[0]:e;o[1]=d.test(o[1])?o[1]:g;i[this]=o});if(n.length==1){n[1]=n[0]}m[0]=parseInt(m[0],10)||0;if(m.length==1){m[1]=m[0]}m[1]=parseInt(m[1],10)||0;switch(i.at[0]){case"right":j.left+=k;break;case e:j.left+=k/2;break}switch(i.at[1]){case"bottom":j.top+=h;break;case g:j.top+=h/2;break}j.left+=m[0];j.top+=m[1];return this.each(function(){var t=f(this),s=t.outerWidth(),r=t.outerHeight(),p=f.extend({},j),u,o,q;switch(i.my[0]){case"right":p.left-=s;break;case e:p.left-=s/2;break}switch(i.my[1]){case"bottom":p.top-=r;break;case g:p.top-=r/2;break}f.each(["left","top"],function(w,v){(f.ui.position[n[w]]&&f.ui.position[n[w]][v](p,{targetWidth:k,targetHeight:h,elemWidth:s,elemHeight:r,offset:m,my:i.my,at:i.at}))});(f.fn.bgiframe&&t.bgiframe());t.offset(f.extend(p,{using:i.using}))})};f.ui.position={fit:{left:function(h,i){var j=h.left+i.elemWidth-f(window).width()-f(window).scrollLeft();h.left=j>0?h.left-j:Math.max(0,h.left)},top:function(h,i){var j=h.top+i.elemHeight-f(window).height()-f(window).scrollTop();h.top=j>0?h.top-j:Math.max(0,h.top)}},flip:{left:function(i,j){if(j.at[0]=="center"){return}var k=i.left+j.elemWidth-f(window).width()-f(window).scrollLeft(),h=j.my[0]=="left"?-j.elemWidth:j.my[0]=="right"?j.elemWidth:0,l=-2*j.offset[0];i.left+=i.left<0?h+j.targetWidth+l:k>0?h-j.targetWidth+l:0},top:function(i,k){if(k.at[1]=="center"){return}var l=i.top+k.elemHeight-f(window).height()-f(window).scrollTop(),h=k.my[1]=="top"?-k.elemHeight:k.my[1]=="bottom"?k.elemHeight:0,j=k.at[1]=="top"?k.targetHeight:-k.targetHeight,m=-2*k.offset[1];i.top+=i.top<0?h+k.targetHeight+m:l>0?h+j+m:0}}};if(!f.offset.setOffset){f.offset.setOffset=function(l,i){if(/static/.test(jQuery.curCSS(l,"position"))){l.style.position="relative"}var k=jQuery(l),n=k.offset(),h=parseInt(jQuery.curCSS(l,"top",true),10)||0,m=parseInt(jQuery.curCSS(l,"left",true),10)||0,j={top:(i.top-n.top)+h,left:(i.left-n.left)+m};if("using" in i){i.using.call(l,j)}else{k.css(j)}};var b=f.fn.offset;f.fn.offset=function(h){var i=this[0];if(!i||!i.ownerDocument){return null}if(h){return this.each(function(){f.offset.setOffset(this,h)})}return b.call(this)}}})(jQuery);;/* 67 | * jQuery UI Effects 1.8rc1 68 | * 69 | * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) 70 | * Dual licensed under the MIT (MIT-LICENSE.txt) 71 | * and GPL (GPL-LICENSE.txt) licenses. 72 | * 73 | * http://docs.jquery.com/UI/Effects/ 74 | */ jQuery.effects||(function(g){g.effects={};g.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(l,k){g.fx.step[k]=function(m){if(!m.colorInit){m.start=j(m.elem,k);m.end=i(m.end);m.colorInit=true}m.elem.style[k]="rgb("+Math.max(Math.min(parseInt((m.pos*(m.end[0]-m.start[0]))+m.start[0],10),255),0)+","+Math.max(Math.min(parseInt((m.pos*(m.end[1]-m.start[1]))+m.start[1],10),255),0)+","+Math.max(Math.min(parseInt((m.pos*(m.end[2]-m.start[2]))+m.start[2],10),255),0)+")"}});function i(l){var k;if(l&&l.constructor==Array&&l.length==3){return l}if(k=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(l)){return[parseInt(k[1],10),parseInt(k[2],10),parseInt(k[3],10)]}if(k=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(l)){return[parseFloat(k[1])*2.55,parseFloat(k[2])*2.55,parseFloat(k[3])*2.55]}if(k=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(l)){return[parseInt(k[1],16),parseInt(k[2],16),parseInt(k[3],16)]}if(k=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(l)){return[parseInt(k[1]+k[1],16),parseInt(k[2]+k[2],16),parseInt(k[3]+k[3],16)]}if(k=/rgba\(0, 0, 0, 0\)/.exec(l)){return a.transparent}return a[g.trim(l).toLowerCase()]}function j(m,k){var l;do{l=g.curCSS(m,k);if(l!=""&&l!="transparent"||g.nodeName(m,"body")){break}k="backgroundColor"}while(m=m.parentNode);return i(l)}var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]};var e=["add","remove","toggle"],c={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};function f(){var n=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,o={},l,m;if(n&&n.length&&n[0]&&n[n[0]]){var k=n.length;while(k--){l=n[k];if(typeof n[l]=="string"){m=l.replace(/\-(\w)/g,function(p,q){return q.toUpperCase()});o[m]=n[l]}}}else{for(l in n){if(typeof n[l]==="string"){o[l]=n[l]}}}return o}function b(l){var k,m;for(k in l){m=l[k];if(m==null||g.isFunction(m)||k in c||(/scrollbar/).test(k)||(!(/color/i).test(k)&&isNaN(parseFloat(m)))){delete l[k]}}return l}function h(k,m){var n={_:0},l;for(l in m){if(k[l]!=m[l]){n[l]=m[l]}}return n}g.effects.animateClass=function(k,l,n,m){if(g.isFunction(n)){m=n;n=null}return this.each(function(){var r=g(this),o=r.attr("style")||" ",s=b(f.call(this)),q,p=r.attr("className");g.each(e,function(t,u){if(k[u]){r[u+"Class"](k[u])}});q=b(f.call(this));r.attr("className",p);r.animate(h(s,q),l,n,function(){g.each(e,function(t,u){if(k[u]){r[u+"Class"](k[u])}});if(typeof r.attr("style")=="object"){r.attr("style").cssText="";r.attr("style").cssText=o}else{r.attr("style",o)}if(m){m.apply(this,arguments)}})})};g.fn.extend({_addClass:g.fn.addClass,addClass:function(l,k,n,m){return k?g.effects.animateClass.apply(this,[{add:l},k,n,m]):this._addClass(l)},_removeClass:g.fn.removeClass,removeClass:function(l,k,n,m){return k?g.effects.animateClass.apply(this,[{remove:l},k,n,m]):this._removeClass(l)},_toggleClass:g.fn.toggleClass,toggleClass:function(m,l,k,o,n){if(typeof l=="boolean"||l===undefined){if(!k){return this._toggleClass(m,l)}else{return g.effects.animateClass.apply(this,[(l?{add:m}:{remove:m}),k,o,n])}}else{return g.effects.animateClass.apply(this,[{toggle:m},l,k,o])}},switchClass:function(k,m,l,o,n){return g.effects.animateClass.apply(this,[{add:m,remove:k},l,o,n])}});g.extend(g.effects,{version:"1.8rc1",save:function(l,m){for(var k=0;k").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0});k.wrap(m);if(k.css("position")=="static"){m.css({position:"relative"});k.css({position:"relative"})}else{g.extend(l,{position:k.css("position"),zIndex:k.css("z-index")});g.each(["top","left","bottom","right"],function(n,o){l[o]=k.css(o);if(isNaN(parseInt(l[o],10))){l[o]="auto"}});k.css({position:"relative",top:0,left:0})}return m.css(l).show()},removeWrapper:function(k){if(k.parent().is(".ui-effects-wrapper")){return k.parent().replaceWith(k)}return k},setTransition:function(l,n,k,m){m=m||{};g.each(n,function(p,o){unit=l.cssUnit(o);if(unit[0]>0){m[o]=unit[0]*k+unit[1]}});return m}});function d(l,k,m,n){if(typeof l=="object"){n=k;m=null;k=l;l=k.effect}if(g.isFunction(k)){n=k;m=null;k={}}if(typeof k=="number"){n=m;m=k;k={}}k=k||{};m=m||k.duration;m=g.fx.off?0:typeof m=="number"?m:g.fx.speeds[m]||g.fx.speeds._default;n=n||k.complete;return[l,k,m,n]}g.fn.extend({effect:function(n,m,p,q){var l=d.apply(this,arguments),o={options:l[1],duration:l[2],callback:l[3]},k=g.effects[n];return k&&!g.fx.off?k.call(this,o):this},_show:g.fn.show,show:function(l){if(!l||typeof l=="number"||g.fx.speeds[l]){return this._show.apply(this,arguments)}else{var k=d.apply(this,arguments);k[1].mode="show";return this.effect.apply(this,k)}},_hide:g.fn.hide,hide:function(l){if(!l||typeof l=="number"||g.fx.speeds[l]){return this._hide.apply(this,arguments)}else{var k=d.apply(this,arguments);k[1].mode="hide";return this.effect.apply(this,k)}},__toggle:g.fn.toggle,toggle:function(l){if(!l||typeof l=="number"||g.fx.speeds[l]||typeof l=="boolean"||g.isFunction(l)){return this.__toggle.apply(this,arguments)}else{var k=d.apply(this,arguments);k[1].mode="toggle";return this.effect.apply(this,k)}},cssUnit:function(k){var l=this.css(k),m=[];g.each(["em","px","%","pt"],function(n,o){if(l.indexOf(o)>0){m=[parseFloat(l),o]}});return m}});g.easing.jswing=g.easing.swing;g.extend(g.easing,{def:"easeOutQuad",swing:function(l,m,k,o,n){return g.easing[g.easing.def](l,m,k,o,n)},easeInQuad:function(l,m,k,o,n){return o*(m/=n)*m+k},easeOutQuad:function(l,m,k,o,n){return -o*(m/=n)*(m-2)+k},easeInOutQuad:function(l,m,k,o,n){if((m/=n/2)<1){return o/2*m*m+k}return -o/2*((--m)*(m-2)-1)+k},easeInCubic:function(l,m,k,o,n){return o*(m/=n)*m*m+k},easeOutCubic:function(l,m,k,o,n){return o*((m=m/n-1)*m*m+1)+k},easeInOutCubic:function(l,m,k,o,n){if((m/=n/2)<1){return o/2*m*m*m+k}return o/2*((m-=2)*m*m+2)+k},easeInQuart:function(l,m,k,o,n){return o*(m/=n)*m*m*m+k},easeOutQuart:function(l,m,k,o,n){return -o*((m=m/n-1)*m*m*m-1)+k},easeInOutQuart:function(l,m,k,o,n){if((m/=n/2)<1){return o/2*m*m*m*m+k}return -o/2*((m-=2)*m*m*m-2)+k},easeInQuint:function(l,m,k,o,n){return o*(m/=n)*m*m*m*m+k},easeOutQuint:function(l,m,k,o,n){return o*((m=m/n-1)*m*m*m*m+1)+k},easeInOutQuint:function(l,m,k,o,n){if((m/=n/2)<1){return o/2*m*m*m*m*m+k}return o/2*((m-=2)*m*m*m*m+2)+k},easeInSine:function(l,m,k,o,n){return -o*Math.cos(m/n*(Math.PI/2))+o+k},easeOutSine:function(l,m,k,o,n){return o*Math.sin(m/n*(Math.PI/2))+k},easeInOutSine:function(l,m,k,o,n){return -o/2*(Math.cos(Math.PI*m/n)-1)+k},easeInExpo:function(l,m,k,o,n){return(m==0)?k:o*Math.pow(2,10*(m/n-1))+k},easeOutExpo:function(l,m,k,o,n){return(m==n)?k+o:o*(-Math.pow(2,-10*m/n)+1)+k},easeInOutExpo:function(l,m,k,o,n){if(m==0){return k}if(m==n){return k+o}if((m/=n/2)<1){return o/2*Math.pow(2,10*(m-1))+k}return o/2*(-Math.pow(2,-10*--m)+2)+k},easeInCirc:function(l,m,k,o,n){return -o*(Math.sqrt(1-(m/=n)*m)-1)+k},easeOutCirc:function(l,m,k,o,n){return o*Math.sqrt(1-(m=m/n-1)*m)+k},easeInOutCirc:function(l,m,k,o,n){if((m/=n/2)<1){return -o/2*(Math.sqrt(1-m*m)-1)+k}return o/2*(Math.sqrt(1-(m-=2)*m)+1)+k},easeInElastic:function(l,n,k,u,r){var o=1.70158;var q=0;var m=u;if(n==0){return k}if((n/=r)==1){return k+u}if(!q){q=r*0.3}if(m 6 |

7 | 8 | book 9 | 10 | Sharing and Updating Projects 11 |

12 |
13 |

14 | Git doesn't have a central server like Subversion. All of the commands 15 | so far have been done locally, just updating a local database. 16 | To collaborate with other developers in Git, you have to put all that 17 | data on a server that the other developers have access to. The way Git 18 | does this is to synchronize your data with another repository. There 19 | is no real difference between a server and a client - a Git repository 20 | is a Git repository and you can synchronize between any two easily. 21 |

22 | 23 |

Once you have a Git repository, either one that you set up on your 24 | own server, or one hosted someplace like GitHub, you can tell Git to 25 | either push any data that you have that is not in the remote repository 26 | up, or you can ask Git to fetch differences down from the other repo. 27 |

28 | 29 |

You can do this any time you are online, it does not have to correspond 30 | with a commit or anything else. Generally you will do a 31 | number of commits locally, then fetch data from the online shared repository 32 | you cloned the project from to get up to date, merge any new work into the 33 | stuff you did, then push your changes back up.

34 | 35 |

36 | In a nutshell you can update your project with git fetch 37 | and share your changes with git push. You can manage your 38 | remote repositories with git remote. 39 |

40 |
41 | 42 | 43 |
44 |

45 | 46 | docs   47 | book 48 | 49 | git remote 50 | list, add and delete remote repository aliases 51 |

52 | 53 |
54 | 55 |

Unlike centralized version control systems that have a client that is 56 | very different from a server, Git repositories are all basically equal and 57 | you simply synchronize between them. This makes it easy to have more than 58 | one remote repository - you can have some that you have read-only access to 59 | and others that you can write to as well.

60 | 61 |

So that you don't have to use the full URL of a remote repository every 62 | time you want to synchronize with it, Git stores an alias or nickname for 63 | each remote repository URL you are interested in. You use the 64 | git remote command to manage this list of remote repos that 65 | you care about.

66 | 67 |

68 | git remote 69 | list your remote aliases 70 |

71 | 72 |

Without any arguments, Git will simply show you the remote repository 73 | aliases that it has stored. By default, if you cloned the project (as 74 | opposed to creating a new one locally), Git will automatically add the 75 | URL of the repository that you cloned from under the name 'origin'. If 76 | you run the command with the -v option, you can see the 77 | actual URL for each alias.

78 | 79 |
 80 | $ git remote
 81 | origin
 82 | $ git remote -v
 83 | origin	git@github.com:github/git-reference.git (fetch)
 84 | origin	git@github.com:github/git-reference.git (push)
 85 | 
86 | 87 |

You see the URL there twice because Git allows you to have different 88 | push and fetch URLs for each remote in case you want to use different 89 | protocols for reads and writes.

90 | 91 |

92 | git remote add 93 | add a new remote repository of your project 94 |

95 | 96 |

If you want to share a locally created repository, or you want to take 97 | contributions from someone else's repository - if you want to interact in 98 | any way with a new repository, it's generally easiest to add it as a remote. 99 | You do that by running git remote add [alias] [url]. That 100 | adds [url] under a local remote named [alias].

101 | 102 |

For example, if we want to share our Hello World program with the world, 103 | we can create a new repository on a server (Using GitHub as an example), 104 | which should give you a URL, in this case "git@github.com:schacon/hw.git". 105 | To add that to our project so we can push to it and fetch updates from it 106 | we would do this:

107 | 108 |
109 | $ git remote
110 | $ git remote add github git@github.com:schacon/hw.git
111 | $ git remote -v
112 | github	git@github.com:schacon/hw.git (fetch)
113 | github	git@github.com:schacon/hw.git (push)
114 | 
115 | 116 |

Like the branch naming, remote alias names are arbitrary - just as 'master' 117 | has no special meaning but is widely used because git init 118 | sets it up by default, 'origin' is often used as a remote name because 119 | git clone sets it up by default as the cloned-from URL. In 120 | this case we'll name the remote 'github', but you could name it just 121 | about anything. 122 |

123 | 124 |

125 | git remote rm 126 | removing an existing remote alias 127 |

128 | 129 |

Git addeth and Git taketh away. If you need to remove a remote - you are 130 | not using it anymore, the project is gone, etc - you can remove it with 131 | git remote rm [alias].

132 | 133 |
134 | $ git remote -v
135 | github	git@github.com:schacon/hw.git (fetch)
136 | github	git@github.com:schacon/hw.git (push)
137 | $ git remote add origin git://github.com/pjhyett/hw.git
138 | $ git remote -v
139 | github	git@github.com:schacon/hw.git (fetch)
140 | github	git@github.com:schacon/hw.git (push)
141 | origin	git://github.com/pjhyett/hw.git (fetch)
142 | origin	git://github.com/pjhyett/hw.git (push)
143 | $ git remote rm origin
144 | $ git remote -v
145 | github	git@github.com:schacon/hw.git (fetch)
146 | github	git@github.com:schacon/hw.git (push)
147 | 
148 | 149 |

150 | git remote rename [old-alias] [new-alias] 151 | rename remote aliases 152 |

153 | 154 |

If you want to rename remote aliases without having to delete them and add them again 155 | you can do that by running git remote rename [old-alias] [new-alias]. This will 156 | allow you to modify the current name of the remote.

157 | 158 |
159 | $ git remote add github git@github.com:schacon/hw.git
160 | $ git remote -v
161 | github	git@github.com:schacon/hw.git (fetch)
162 | github	git@github.com:schacon/hw.git (push)
163 | $ git remote rename github origin
164 | $ git remote -v
165 | origin	git@github.com:schacon/hw.git (fetch)
166 | origin	git@github.com:schacon/hw.git (push)
167 | 
168 | 169 |

170 | In a nutshell with git remote you can list our 171 | remote repositories and whatever URL 172 | that repository is using. You can use git remote add to 173 | add new remotes, git remote rm to delete existing ones or git remote rename [old-alias] [new-alias] to rename them. 174 |

175 | 176 |

177 | git remote set-url 178 | update an existing remote URL 179 |

180 | 181 |

Should you ever need to update a remote's URL, you can do so with 182 | the git remote set-url command. 183 |

184 | 185 |
186 | $ git remote -v
187 | github	git@github.com:schacon/hw.git (fetch)
188 | github	git@github.com:schacon/hw.git (push)
189 | origin	git://github.com/pjhyett/hw.git (fetch)
190 | origin	git://github.com/pjhyett/hw.git (push)
191 | $ git remote set-url origin git://github.com/github/git-reference.git
192 | $ git remote -v
193 | github	git@github.com:schacon/hw.git (fetch)
194 | github	git@github.com:schacon/hw.git (push)
195 | origin	git://github.com/github/git-reference.git (fetch)
196 | origin	git://github.com/github/git-reference.git (push)
197 | 
198 | 199 |

In addition to this, you can set a different push URL when you 200 | include the --push flag. This allows you to fetch from 201 | one repo while pushing to another and yet both use the same remote alias. 202 |

203 | 204 |
205 | $ git remote -v
206 | github	git@github.com:schacon/hw.git (fetch)
207 | github	git@github.com:schacon/hw.git (push)
208 | origin	git://github.com/github/git-reference.git (fetch)
209 | origin	git://github.com/github/git-reference.git (push)
210 | $ git remote set-url --push origin git://github.com/pjhyett/hw.git
211 | $ git remote -v
212 | github	git@github.com:schacon/hw.git (fetch)
213 | github	git@github.com:schacon/hw.git (push)
214 | origin	git://github.com/github/git-reference.git (fetch)
215 | origin	git://github.com/pjhyett/hw.git (push)
216 | 
217 | 218 |

Internally, the git remote set-url command calls 219 | git config remote, but has the added benefit of reporting 220 | back any errors. git config remote on the other hand, will 221 | silently fail if you mistype an argument or option and not actually set 222 | anything. 223 |

224 | 225 |

For example, we'll update the github remote but 226 | instead reference it as guhflub in both invocations. 227 |

228 | 229 |
230 | $ git remote -v
231 | github	git@github.com:schacon/hw.git (fetch)
232 | github	git@github.com:schacon/hw.git (push)
233 | origin	git://github.com/github/git-reference.git (fetch)
234 | origin	git://github.com/github/git-reference.git (push)
235 | $ git config remote.guhflub git://github.com/mojombo/hw.git
236 | $ git remote -v
237 | github	git@github.com:schacon/hw.git (fetch)
238 | github	git@github.com:schacon/hw.git (push)
239 | origin	git://github.com/github/git-reference.git (fetch)
240 | origin	git://github.com/github/git-reference.git (push)
241 | $ git remote set-url guhflub git://github.com/mojombo/hw.git
242 | fatal: No such remote 'guhflub'
243 | 
244 | 245 |

246 | In a nutshell, you can update the locations of your remotes 247 | with git remote set-url. You can also set different push 248 | and fetch URLs under the same remote alias. 249 |

250 | 251 |
252 |
253 | 254 |
255 |

256 | 257 | docs   258 | book 259 | 260 | git fetch 261 | download new branches and data from a remote repository 262 |

263 | 264 |
265 | 266 |

267 | 268 | docs   269 | book 270 | 271 | git pull 272 | fetch from a remote repo and try to merge into the current branch 273 |

274 | 275 |
276 | 277 |

Git has two commands to update itself from a remote repository. 278 | git fetch will synchronize you with another repo, pulling down any data 279 | that you do not have locally and giving you bookmarks to where each branch on 280 | that remote was when you synchronized. These are called "remote branches" and are 281 | identical to local branches except that Git will not allow you to check them out - 282 | however, you can merge from them, diff them to other branches, run history logs on 283 | them, etc. You do all of that stuff locally after you synchronize. 284 |

285 | 286 |

The second command that will fetch down new data from a remote server is 287 | git pull. This command will basically run a git fetch 288 | immediately followed by a git merge of the branch on that remote 289 | that is tracked by whatever branch you are currently in. Running the 290 | fetch and merge commands separately involves less magic 291 | and less problems, but if you like the idea of pull, you can 292 | read about it in more detail in the 293 | official docs. 294 |

295 | 296 |

Assuming you have a remote all set up and you want to pull in updates, you 297 | would first run git fetch [alias] to tell Git to fetch down all the 298 | data it has that you do not, then you would run git merge [alias]/[branch] 299 | to merge into your current branch anything new you see on the server 300 | (like if someone else has pushed in the meantime). So, if you were working on a 301 | Hello World project with several other people and wanted to bring in any changes 302 | that had been pushed since we last connected, we would do something like this:

303 | 304 |
305 | $ git fetch github
306 | remote: Counting objects: 4006, done.
307 | remote: Compressing objects: 100% (1322/1322), done.
308 | remote: Total 2783 (delta 1526), reused 2587 (delta 1387)
309 | Receiving objects: 100% (2783/2783), 1.23 MiB | 10 KiB/s, done.
310 | Resolving deltas: 100% (1526/1526), completed with 387 local objects.
311 | From github.com:schacon/hw
312 |    8e29b09..c7c5a10  master     -> github/master
313 |    0709fdc..d4ccf73  c-langs    -> github/c-langs
314 |    6684f82..ae06d2b  java       -> github/java
315 |  * [new branch]      ada        -> github/ada
316 |  * [new branch]      lisp       -> github/lisp
317 | 
318 | 319 |

Here we can see that since we last synchronized with this remote, five branches 320 | have been added or updated. The 'ada' and 'lisp' branches are new, where the 321 | 'master', 'c-langs' and 'java' branches have been updated. In our example case, 322 | other developers are pushing proposed updates to remote branches for review before 323 | they're merged into 'master'. 324 |

325 | 326 |

You can see the mapping that Git makes. The 'master' branch on the remote 327 | repository becomes a branch named 'github/master' locally. That way you can 328 | merge the 'master' branch on that remote into the local 'master' branch by running 329 | git merge github/master. Or, you can see what new commits are on that 330 | branch by running git log github/master ^master. If your remote 331 | is named 'origin' it would be origin/master instead. Almost any 332 | command you would run using local branches you can use remote branches with too. 333 |

334 | 335 |

If you have more than one remote repository, you can either fetch from specific 336 | ones by running git fetch [alias] or you can tell Git to synchronize 337 | with all of your remotes by running git fetch --all. 338 |

339 | 340 |

341 | In a nutshell you run git fetch [alias] to synchronize your 342 | repository with a remote repository, fetching all the data it has that you do 343 | not into branch references locally for merging and whatnot. 344 |

345 | 346 |
347 | 348 |
349 | 350 |
351 |

352 | 353 | docs   354 | book 355 | 356 | git push 357 | push your new branches and data to a remote repository 358 |

359 | 360 |
361 |

To share the cool commits you've done with others, you need to push your 362 | changes to the remote repository. To do this, you run 363 | git push [alias] [branch] which will attempt to make your [branch] 364 | the new [branch] on the [alias] remote. Let's try it by initially pushing 365 | our 'master' branch to the new 'github' remote we created earlier.

366 | 367 |
368 | $ git push github master
369 | Counting objects: 25, done.
370 | Delta compression using up to 2 threads.
371 | Compressing objects: 100% (25/25), done.
372 | Writing objects: 100% (25/25), 2.43 KiB, done.
373 | Total 25 (delta 4), reused 0 (delta 0)
374 | To git@github.com:schacon/hw.git
375 |  * [new branch]      master -> master
376 | 
377 | 378 |

Pretty easy. Now if someone clones that repository they will get exactly 379 | what we have committed and all of its history.

380 | 381 |

What if you have a topic branch like the 'erlang' branch created earlier 382 | and want to share just that? You can just push that branch instead.

383 | 384 |
385 | $ git push github erlang
386 | Counting objects: 7, done.
387 | Delta compression using up to 2 threads.
388 | Compressing objects: 100% (6/6), done.
389 | Writing objects: 100% (6/6), 652 bytes, done.
390 | Total 6 (delta 1), reused 0 (delta 0)
391 | To git@github.com:schacon/hw.git
392 |  * [new branch]      erlang -> erlang
393 | 
394 | 395 |

Now when people clone or fetch from that repository, they'll get an 'erlang' 396 | branch they can look at and merge from. You can push any branch to any 397 | remote repository that you have write access to in this way. If your branch 398 | is already on the server, it will try to update it, if it is not, Git will 399 | add it.

400 | 401 |

The last major issue you run into with pushing to remote branches is the 402 | case of someone pushing in the meantime. If you and another developer clone 403 | at the same time, you both do commits, then she pushes and then you try to 404 | push, Git will by default not allow you to overwrite her changes. Instead, 405 | it basically runs git log on the branch you're trying to push and 406 | makes sure it can see the current tip of the server's branch in your push's 407 | history. If it can't see what is on the server in your history, it concludes 408 | that you are out of date and will reject your push. You will rightly have to 409 | fetch, merge then push again - which makes sure you take her changes into 410 | account.

411 | 412 |

This is what happens when you try to push a branch to a remote branch 413 | that has been updated in the meantime:

414 | 415 |
416 | $ git push github master
417 | To git@github.com:schacon/hw.git
418 |  ! [rejected]        master -> master (non-fast-forward)
419 | error: failed to push some refs to 'git@github.com:schacon/hw.git'
420 | To prevent you from losing history, non-fast-forward updates were rejected
421 | Merge the remote changes before pushing again.  See the 'Note about
422 | fast-forwards' section of 'git push --help' for details.
423 | 
424 | 425 |

You can fix this by running git fetch github; git merge github/master 426 | and then pushing again. 427 |

428 | 429 |

430 | In a nutshell you run git push [alias] [branch] to update a 431 | remote repository with the changes you've made locally. It will take what your 432 | [branch] looks like and push it to be [branch] on the remote, if possible. If 433 | someone else has pushed since you last fetched and merged, the Git server will 434 | deny your push until you are up to date. 435 |

436 | 437 |
438 |
439 | 440 |

On to Inspection and Comparison »

441 | -------------------------------------------------------------------------------- /zh/.gitignore: -------------------------------------------------------------------------------- 1 | _site 2 | *~ 3 | -------------------------------------------------------------------------------- /zh/about.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: zh_reference 3 | --- 4 |
5 |

谁的作品?

6 |
7 |

Git 参考手册是 Github 项目组的成果。

8 |

逸才Git Reference 的基础上做了中文翻译。

9 |
10 | -------------------------------------------------------------------------------- /zh/basic/index.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: zh_reference 3 | --- 4 | 5 |
6 |

7 | 8 | 9 | 10 | 基本快照 11 |

12 |
13 |

14 | Git 的工作就是创建和保存你的项目的快照及与之后的快照进行对比。本章将对有关创建与提交你的项目的快照的命令作介绍。 15 |

16 | 17 |

18 | 这里有个重要的概念,Git 有一个叫做“索引”的东东,有点像是你的快照的缓存区。这就使你能够从更改的文件中创建出一系列组织良好的快照,而不是一次提交所有的更改。 19 |

20 | 21 |

22 | 简而言之,使用 git add 添加需要追踪的新文件和待提交的更改, 23 | 然后使用 git statusgit diff 查看有何改动, 24 | 最后用 git commit 将你的快照记录。这就是你要用的基本流程,绝大部分时候都是这样的。 25 |

26 | 27 |
28 |
29 | 30 |
31 |

32 | 33 | 文档   34 | 35 | 36 | git add 37 | 添加文件到缓存 38 |

39 | 40 |
41 |

42 | 在 Git 中,在提交你修改的文件之前,你需要把它们添加到缓存。如果该文件是新创建的,你可以执行 43 | git add 将该文件添加到缓存,但是,即使该文件已经被追踪了 —— 也就是说,曾经提交过了 —— 44 | 你仍然需要执行 git add 将新更改的文件添加到缓存去。让我们看几个例子: 45 |

46 | 47 |

回到我们的 Hello World 示例,初始化该项目之后,我们就要用 git add 将我们的文件添加进去了。 48 | 我们可以用 git status 看看我们的项目的当前状态。 49 |

50 | 51 |
 52 | $ git status -s
 53 | ?? README
 54 | ?? hello.rb
 55 | 
56 | 57 |

我们有俩尚未被追踪的文件,得添加一下。

58 | 59 |
 60 | $ git add README hello.rb
 61 | 
62 | 63 |

现在我们再执行 git status,就可以看到这俩文件已经加上去了。

64 | 65 |
 66 | $ git status -s
 67 | A  README
 68 | A  hello.rb
 69 | 
70 | 71 |

72 | 新项目中,添加所有文件很普遍,可以在当前工作目录执行命令:git add .。 73 | 因为 Git 会递归地将你执行命令时所在的目录中的所有文件添加上去,所以如果你将当前的工作目录作为参数, 74 | 它就会追踪那儿的所有文件了。如此,git add . 就和 git add README hello.rb 75 | 有一样的效果。 76 | 此外,效果一致的还有 git add *,不过那只是因为我们这还木有子目录,不需要递归地添加新文件。 77 |

78 | 79 |

好了,现在我们改个文件,再跑一下 git status,有点古怪。

80 |
 81 | $ vim README
 82 | $ git status -s
 83 | AM README
 84 | A  hello.rb
 85 | 
86 | 87 |

“AM” 状态的意思是,这个文件在我们将它添加到缓存之后又有改动。这意味着如果我们现在提交快照, 88 | 我们记录的将是上次跑 git add 的时候的文件版本,而不是现在在磁盘中的这个。 89 | Git 并不认为磁盘中的文件与你想快照的文件必须是一致的 —— (如果你需要它们一致,)得用 git add 命令告诉它。 90 |

91 | 92 |

93 | 一言以蔽之, 94 | 当你要将你的修改包含在即将提交的快照里的时候,执行 git add。 95 | 任何你没有添加的改动都不会被包含在内 —— 这意味着你可以比绝大多数其他源代码版本控制系统更精确地归置你的快照。 96 |

97 | 98 |

请查看《Pro Git》中 git add 的 “-p” 参数,以了解更多关于提交文件的灵活性的例子。 99 |

100 | 101 |
102 | 103 |
104 | 105 |
106 |

107 | 108 | 文档   109 | 110 | 111 | git status 112 | 查看你的文件在工作目录与缓存的状态 113 |

114 | 115 |
116 |

正如你在 git add 小节中所看到的,你可以执行 git status 117 | 命令查看你的代码在缓存与当前工作目录的状态。我演示该命令的时候加了 -s 参数,以获得简短的结果输出。 118 | 若没有这个标记,命令 git status 将告诉你更多的提示与上下文欣喜。 119 | 以下便是同样状态下,有跟没有 -s 参数的输出对比。简短的输出如下: 120 |

121 | 122 |
123 | $ git status -s
124 | AM README
125 | A  hello.rb
126 | 
127 | 128 |

而同样的状态,详细的输出看起来是这样的:

129 | 130 |
131 | $ git status
132 | # On branch master
133 | #
134 | # Initial commit
135 | #
136 | # Changes to be committed:
137 | #   (use "git rm --cached <file>..." to unstage)
138 | #
139 | # new file:   README
140 | # new file:   hello.rb
141 | #
142 | # Changed but not updated:
143 | #   (use "git add <file>..." to update what will be committed)
144 | #   (use "git checkout -- <file>..." to discard changes in working directory)
145 | #
146 | # modified:   README
147 | #
148 | 
149 | 150 |

你很容易发现简短的输出看起来很紧凑。而详细输出则很有帮助,提示你可以用何种命令完成你接下来可能要做的事情。 151 |

152 | 153 |

Git 还会告诉你在你上次提交之后,有哪些文件被删除、修改或者存入缓存了。

154 | 155 |
156 | $ git status -s
157 | M  README
158 |  D hello.rb
159 | 
160 | 161 |

你可以看到,在简短输出中,有两栏。第一栏是缓存的,第二栏则是工作目录的。 162 | 所以假设你临时提交了 README 文件,然后又改了些,并且没有执行 git add,你会看到这个:

163 | 164 |
165 | $ git status -s
166 | MM README
167 |  D hello.rb
168 | 
169 | 170 |

171 | 一言以蔽之,执行 git status 以查看在你上次提交之后有啥被修改或者临时提交了, 172 | 从而决定自己是否需要提交一次快照,同时也能知道有什么改变被记录进去了。 173 |

174 | 175 |
176 |
177 | 178 |
179 |

180 | 181 | 文档   182 | 183 | 184 | git diff 185 | 显示已写入缓存与已修改但尚未写入缓存的改动的区别 186 |

187 | 188 |
189 |

git diff 有两个主要的应用场景。我们将在此介绍其一, 190 | 在 检阅与对照 一章中,我们将介绍其二。 191 | 我们这里介绍的方式是用此命令描述已临时提交的或者已修改但尚未提交的改动。 192 |

193 | 194 |

195 | git diff 196 | #尚未缓存的改动 197 |

198 | 199 |

如果没有其他参数,git diff 会以规范化的 diff 格式(一个补丁)显示自从你上次提交快照之后尚未缓存的所有更改。 200 |

201 | 202 |
203 | $ vim hello.rb
204 | $ git status -s
205 |  M hello.rb
206 | $ git diff
207 | diff --git a/hello.rb b/hello.rb
208 | index d62ac43..8d15d50 100644
209 | --- a/hello.rb
210 | +++ b/hello.rb
211 | @@ -1,7 +1,7 @@
212 |  class HelloWorld
213 | 
214 |    def self.hello
215 | -    puts "hello world"
216 | +    puts "hola mundo"
217 |    end
218 | 
219 |  end
220 | 
221 | 222 |

所以,git status显示你上次提交更新至后所更改或者写入缓存的改动, 223 | 而 git diff 一行一行地显示这些改动具体是啥。 224 | 通常执行完 git status 之后接着跑一下 git diff 是个好习惯。 225 |

226 | 227 |

228 | git diff --cached 229 | #查看已缓存的改动 230 |

231 | 232 |

git diff --cached 命令会告诉你有哪些内容已经写入缓存了。 233 | 也就是说,此命令显示的是接下来要写入快照的内容。所以,如果你将上述示例中的 hello.rb 234 | 写入缓存,因为 git diff 显示的是尚未缓存的改动,所以在此执行它不会显示任何信息。 235 |

236 | 237 |
238 | $ git status -s
239 |  M hello.rb
240 | $ git add hello.rb 
241 | $ git status -s
242 | M  hello.rb
243 | $ git diff
244 | $ 
245 | 
246 | 247 |

如果你想看看已缓存的改动,你需要执行的是 248 | git diff --cached

249 | 250 |
251 | $ git status -s
252 | M  hello.rb
253 | $ git diff
254 | $ 
255 | $ git diff --cached
256 | diff --git a/hello.rb b/hello.rb
257 | index d62ac43..8d15d50 100644
258 | --- a/hello.rb
259 | +++ b/hello.rb
260 | @@ -1,7 +1,7 @@
261 |  class HelloWorld
262 | 
263 |    def self.hello
264 | -    puts "hello world"
265 | +    puts "hola mundo"
266 |    end
267 | 
268 |  end
269 | 
270 | 271 |

272 | git diff HEAD 273 | 查看已缓存的与未缓存的所有改动 274 |

275 | 276 |

如果你想一并查看已缓存的与未缓存的改动,可以执行 git diff HEAD —— 277 | 也就是说你要看到的是工作目录与上一次提交的更新的区别,无视缓存。 278 | 假设我们又改了些 ruby.rb 的内容,那缓存的与未缓存的改动我们就都有了。 279 | 以上三个 diff 命令的结果如下: 280 |

281 |
282 | $ vim hello.rb 
283 | $ git diff
284 | diff --git a/hello.rb b/hello.rb
285 | index 4f40006..2ae9ba4 100644
286 | --- a/hello.rb
287 | +++ b/hello.rb
288 | @@ -1,7 +1,7 @@
289 |  class HelloWorld
290 | 
291 | +  # says hello
292 |    def self.hello
293 |      puts "hola mundo"
294 |    end
295 | 
296 |  end
297 | $ git diff --cached
298 | diff --git a/hello.rb b/hello.rb
299 | index 2aabb6e..4f40006 100644
300 | --- a/hello.rb
301 | +++ b/hello.rb
302 | @@ -1,7 +1,7 @@
303 |  class HelloWorld
304 | 
305 |    def self.hello
306 | -    puts "hello world"
307 | +    puts "hola mundo"
308 |    end
309 | 
310 |  end
311 | $ git diff HEAD
312 | diff --git a/hello.rb b/hello.rb
313 | index 2aabb6e..2ae9ba4 100644
314 | --- a/hello.rb
315 | +++ b/hello.rb
316 | @@ -1,7 +1,8 @@
317 |  class HelloWorld
318 | 
319 | +  # says hello
320 |    def self.hello
321 | -    puts "hello world"
322 | +    puts "hola mundo"
323 |    end
324 | 
325 |  end
326 | 
327 | 328 |

329 | git diff --stat 330 | 显示摘要而非整个 diff 331 |

332 | 333 |

如果我们不想要看整个 diff 输出,但是又想比 git status 详细点, 334 | 就可以用 --stat 选项。该选项使它显示摘要而非全文。上文示例在使用 --stat 选项时,输出如下: 335 |

336 | 337 |
338 | $ git status -s
339 | MM hello.rb
340 | $ git diff --stat
341 |  hello.rb |    1 +
342 |  1 files changed, 1 insertions(+), 0 deletions(-)
343 | $ git diff --cached --stat
344 |  hello.rb |    2 +-
345 |  1 files changed, 1 insertions(+), 1 deletions(-)
346 | $ git diff HEAD --stat
347 |  hello.rb |    3 ++-
348 |  1 files changed, 2 insertions(+), 1 deletions(-)
349 | 
350 | 351 |

你还可以在上述命令后面制定一个目录,从而只查看特定文件或子目录的 diff 输出。 352 |

353 | 354 | 355 |

356 | 简而言之, 357 | 执行 git diff 来查看执行 git status 的结果的详细信息 —— 358 | 一行一行地显示这些文件是如何被修改或写入缓存的。 359 |

360 | 361 |
362 |
363 | 364 |
365 |

366 | 367 | 文档   368 | 369 | 370 | git commit 371 | 记录缓存内容的快照 372 |

373 | 374 |
375 | 376 |

现在你使用 git add 命令将想要快照的内容写入了缓存, 377 | 执行 git commit 就将它实际存储快照了。 378 | Git 为你的每一个提交都记录你的名字与电子邮箱地址,所以第一步是告诉 Git 这些都是啥。 379 |

380 | 381 |
382 | $ git config --global user.name 'Your Name'
383 | $ git config --global user.email you@somedomain.com
384 | 
385 | 386 |

让我们写入缓存,并提交对 hello.rb 的所有改动。在首个例子中,我们使用 -m 选项以在命令行中提供提交注释。 387 |

388 | 389 |
390 | $ git add hello.rb 
391 | $ git status -s
392 | M  hello.rb
393 | $ git commit -m 'my hola mundo changes'
394 | [master 68aa034] my hola mundo changes
395 |  1 files changed, 2 insertions(+), 1 deletions(-)
396 | 
397 | 398 |

现在我们已经记录了快照。如果我们再执行 git status,会看到我们有一个“干净的工作目录”。 399 | 这意味着我们在最近一次提交之后,没有做任何改动 —— 在我们的项目中没有未快照的工作。 400 |

401 | 402 |
403 | $ git status
404 | # On branch master
405 | nothing to commit (working directory clean)
406 | 
407 | 408 |

如果你漏掉了 -m 选项,Git 会尝试为你打开一个编辑器以填写提交信息。 409 | 如果 Git 在你对它的配置中找不到相关信息,默认会打开 vim。屏幕会像这样: 410 |

411 | 412 |
413 | 
414 | # Please enter the commit message for your changes. Lines starting
415 | # with '#' will be ignored, and an empty message aborts the commit.
416 | # On branch master
417 | # Changes to be committed:
418 | #   (use "git reset HEAD <file>..." to unstage)
419 | #
420 | # modified:   hello.rb
421 | #
422 | ~
423 | ~
424 | ".git/COMMIT_EDITMSG" 9L, 257C
425 | 
426 | 427 |

在此,你在文件头部添加实际的提交信息。以“#”开头的行都会被无视 ——Git 将 git status 的输出结果放在那儿以提示你都改了、缓存了啥。 428 |

429 | 430 |

通常,撰写良好的提交信息是很重要的。以开放源代码项目为例,多多少少以以下格式写你的提示消息是个不成文的规定: 431 |

432 | 433 |
434 | 简短的关于改动的总结(25个字或者更少)
435 | 
436 | 如果有必要,更详细的解释文字。约 36 字时换行。在某些情况下,
437 | 第一行会被作为电子邮件的开头,而剩余的则会作为邮件内容。
438 | 将小结从内容隔开的空行是至关重要的(除非你没有内容);
439 | 如果这两个待在一起,有些 git 工具会犯迷糊。
440 | 
441 | 空行之后是更多的段落。
442 | 
443 |  - 列表也可以
444 | 
445 |  - 通常使用连字符(-)或者星号(*)来标记列表,前面有个空格,
446 |    在列表项之间有空行,不过这些约定也会有些变化。
447 | 
448 | # Please enter the commit message for your changes. Lines starting
449 | # with '#' will be ignored, and an empty message aborts the commit.
450 | # On branch master
451 | # Changes to be committed:
452 | #   (use "git reset HEAD <file>..." to unstage)
453 | #
454 | # modified:   hello.rb
455 | #
456 | ~
457 | ~
458 | ~
459 | ".git/COMMIT_EDITMSG" 25L, 884C written
460 | 
461 | 462 |

463 | 提交注解是很重要的。因为 Git 很大一部分能耐就是它在组织本地提交和与他人分享的弹性, 464 | 它很给力地能够让你为逻辑独立的改变写三到四条提交注解,以便你的工作被同仁审阅。因为提交与推送改动是有区别的, 465 | 请务必花时间将各个逻辑独立的改动放到另外一个提交,并附上一份良好的提交注解, 466 | 以使与你合作的人能够方便地了解你所做的,以及你为何要这么做。 467 |

468 | 469 |

470 | git commit -a 471 | 自动将在提交前将已记录、修改的文件放入缓存区 472 |

473 | 474 |

如果你觉得 git add 提交缓存的流程太过繁琐,Git 也允许你用 -a 选项跳过这一步。 475 | 基本上这句话的意思就是,为任何已有记录的文件执行 git add —— 476 | 也就是说,任何在你最近的提交中已经存在,并且之后被修改的文件。 477 | 这让你能够用更 Subversion 方式的流程,修改些文件,然后想要快照所有所做的改动的时候执行 git commit -a。 478 | 不过你仍然需要执行 git add 来添加新文件,就像 Subversion 一样。 479 |

480 | 481 |
482 | $ vim hello.rb
483 | $ git status -s
484 |  M  hello.rb
485 | $ git commit -m 'changes to hello file'
486 | # On branch master
487 | # Changed but not updated:
488 | #   (use "git add <file>..." to update what will be committed)
489 | #   (use "git checkout -- <file>..." to discard changes in working directory)
490 | #
491 | # modified:   hello.rb
492 | #
493 | no changes added to commit (use "git add" and/or "git commit -a")
494 | $ git commit -am 'changes to hello file'
495 | [master 78b2670] changes to hello file
496 |  1 files changed, 2 insertions(+), 1 deletions(-)
497 | 
498 | 499 |

注意,如果你不缓存改动,直接执行 git commit,Git 会直接给出 git status 500 | 命令的输出,提醒你啥也没缓存。我已将该消息中的重要部分高亮,它说没有添加需要提交的缓存。 501 | 如果你使用 -a,它会缓存并提交每个改动(不含新文件)。 502 |

503 | 504 |

505 | 现在你就完成了整个快照的流程 ——改些文件,然后用 git add 将要提交的改动提交到缓存, 506 | 用 git statusgit diff 看看你都改了啥,最后 git commit 永久地保存快照。 507 |

508 | 509 |

510 | 简而言之,执行 git commit 记录缓存区的快照。如果需要的话,这个快照可以用来做比较、共享以及恢复。 511 |

512 | 513 |
514 |
515 | 516 |
517 |

518 | 519 | 文档   520 | 521 | 522 | git reset HEAD 523 | 取消缓存已缓存的内容 524 |

525 | 526 |
527 |

git reset 可能是人类写的最费解的命令了。 528 | 我用 Git 有些年头了,甚至还写了本书,但有的时候还是会搞不清它会做什么。 529 | 所以,我只说三个明确的,通常有用的调用。请你跟我一样尽管用它 —— 因为它可以很有用。 530 |

531 | 532 |

在此例中,我们可以用它来将不小心缓存的东东取消缓存。假设你修改了两个文件,想要将它们记录到两个不同的提交中去。 533 | 你应该缓存并提交一个,再缓存并提交另外一个。如果你不小心两个都缓存了,那要如何才能取消缓存呢? 534 | 你可以用 git reset HEAD -- file。 535 | 技术上说,在这里你不需要使用 -- —— 它用来告诉 Git 这时你已经不再列选项,剩下的是文件路径了。 536 | 不过养成使用它分隔选项与路径的习惯很重要,即使在你可能并不需要的时候。 537 |

538 | 539 |

好,让我们看看取消缓存是什么样子的。这里我们有两个最近提交之后又有所改动的文件。我们将两个都缓存,并取消缓存其中一个。

540 | 541 |
542 | $ git status -s
543 |  M README
544 |  M hello.rb
545 | $ git add .
546 | $ git status -s
547 | M  README
548 | M  hello.rb
549 | $ git reset HEAD -- hello.rb 
550 | Unstaged changes after reset:
551 | M hello.rb
552 | $ git status -s
553 | M  README
554 |  M hello.rb
555 | 
556 | 557 |

558 | 现在你执行 git commit 将只记录 README 文件的改动,并不含现在并不在缓存中的 hello.rb。 559 |

560 | 561 |

562 | 如果你好奇,它实际的操作是将该文件在“索引”中的校验和重置为最近一次提交中的值。 563 | git add 会计算一个文件的校验和,将它添加到“索引”中, 564 | 而 git reset HEAD 将它改写回原先的,从而取消缓存操作。 565 |

566 | 567 |

568 | 如果你想直接执行 git unstage,你可以在 Git 中配置个别名。 569 | 执行 git config --global alias.unstage "reset HEAD" 即可。 570 | 一旦执行完它,你就可以直接用 git unstage [file] 作为代替了。 571 |

572 | 573 |

如果你忘了取消缓存的命令,Git 的常规 git status 输出的提示会很有帮助。 574 | 例如,在你有已缓存的文件时,如果你不带 -s 执行 git status,它将告诉你怎样取消缓存: 575 |

576 | 577 |
578 | $ git status
579 | # On branch master
580 | # Changes to be committed:
581 | #   (use "git reset HEAD <file>..." to unstage)
582 | #
583 | #   modified:   README
584 | #   modified:   hello.rb
585 | #
586 | 
587 | 588 |

589 | 简而言之,执行 git reset HEAD 以取消之前 git add 添加,但不希望包含在下一提交快照中的缓存。 590 |

591 | 592 |
593 |
594 | 595 |
596 |

597 | 598 | 文档   599 | 600 | 601 | git rm 602 | 将文件从缓存区移除 603 |

604 | 605 |
606 | 607 |

608 | git rm 会将条目从缓存区中移除。这与 git reset HEAD 将条目取消缓存是有区别的。 609 | “取消缓存”的意思就是将缓存区恢复为我们做出修改之前的样子。 610 | 在另一方面,git rm 则将该文件彻底从缓存区踢出,因此它不再下一个提交快照之内,进而有效地删除它。 611 |

612 | 613 |

614 | 默认情况下,git rm file 会将文件从缓存区和你的硬盘中(工作目录)删除。 615 | 如果要在工作目录中留着该文件,可以使用 git rm --cached 616 |

617 | 618 |

619 | git mv 620 | git rm --cached orig; mv orig new; git add new 621 |

622 | 623 |

624 | 不像绝大多数其他版本控制系统,Git 并不记录记录文件重命名。它反而只记录快照,并对比快照以找到有啥文件可能被重命名了。 625 | 如果一个文件从更新中删除了,而在下次快照中新添加的另一个文件的内容与它很相似,Git 就知道这极有可能是个重命名。 626 | 因此,虽然有 git mv 命令,但它有点多余 —— 它做得所有事情就是 git rm --cached, 627 | 重命名磁盘上的文件,然后再执行 git add 把新文件添加到缓存区。 628 | 你并不需要用它,不过如果觉得这样容易些,尽管用吧。 629 |

630 | 631 |

632 | 我自己并不使用此命令的普通形式 —— 删除文件。通常直接从硬盘删除文件,然后执行 git commit -a 会简单些。 633 | 它会自动将删除的文件从索引中移除。 634 |

635 | 636 |

637 | 简而言之, 638 | 执行 git rm 来删除 Git 追踪的文件。它还会删除你的工作目录中的相应文件。 639 |

640 | 641 |
642 |
643 | 644 |

到 分支与合并 »

645 | -------------------------------------------------------------------------------- /zh/branching/index.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: zh_reference 3 | --- 4 | 5 |
6 |

7 | 8 | 9 | 10 | 分支与合并 11 |

12 |
13 |

分支是我最喜欢的 Git 特性之一。如果你用过其他版本控制系统,把你所知的分支给忘记,倒可能更有帮助些 —— 14 | 事实上,以我们使用分支的方式,把 Git 的分支看作 上下文 反而更合适。 15 | 当你检出分支时,你可以在两三个不同的分支之间来回切换。 16 |

17 | 18 |

19 | 简而言之,你可以执行 git branch (branchname) 来创建分支, 20 | 使用 git checkout (branchname) 命令切换到该分支,在该分支的上下文环境中, 21 | 提交快照等,之后可以很容易地来回切换。当你切换分支的时候,Git 会用该分支的最后提交的快照替换你的工作目录的内容, 22 | 所以多个分支不需要多个目录。使用 git merge 来合并分支。你可以多次合并到统一分支, 23 | 也可以选择在合并之后直接删除被并入的分支。 24 |

25 | 26 |
27 |
28 | 29 |
30 |

31 | 32 | 文档   33 | 34 | 35 | git branch 36 | 列出、创建与管理工作上下文 37 |

38 | 39 |
40 | 41 |

42 | 43 | 文档   44 | 45 | 46 | git checkout 47 | 切换到新的分支上下文 48 |

49 | 50 |
51 |

git branch 命令是 Git 中的通用分支管理工具,可以通过它完成多项任务。 52 | 我们先说你会用到的最多的命令 —— 列出分支、创建分支和删除分支。 53 | 我们还会介绍用来切换分支的 git checkout 命令。 54 |

55 | 56 |

57 | git branch 58 | 列出可用的分支 59 |

60 | 61 |

没有参数时,git branch 会列出你在本地的分支。你所在的分支的行首会有个星号作标记。 62 | 如果你开启了彩色模式,当前分支会用绿色显示。 63 |

64 | 65 |
 66 | $ git branch
 67 | * master
 68 | 
69 | 70 |

此例的意思就是,我们有一个叫做“master”的分支,并且该分支是当前分支。 71 | 当你执行 git init 的时候,缺省情况下 Git 就会为你创建“master”分支。 72 | 但是这名字一点特殊意味都没有 —— 事实上你并不非得要一个叫做“master”的分支。 73 | 不过由于它是缺省分支名的缘故,绝大部分项目都有这个分支。 74 |

75 | 76 |

77 | git branch (branchname) 78 | 创建新分支 79 |

80 | 81 |

我们动手创建一个分支,并切换过去。执行 git branch (branchname) 即可。 82 |

83 | 84 |
 85 | $ git branch testing
 86 | $ git branch
 87 | * master
 88 |   testing
 89 | 
90 | 91 |

现在我们可以看到,有了一个新分支。当你以此方式在上次提交更新之后创建了新分支,如果后来又有更新提交, 92 | 然后又切换到了“testing”分支,Git 将还原你的工作目录到你创建分支时候的样子 —— 93 | 你可以把它看作一个记录你当前进度的书签。让我们实际运用看看 —— 94 | 我们用 git checkout (branch) 切换到我们要修改的分支。 95 |

96 | 97 |
 98 | $ ls
 99 | README   hello.rb
100 | $ echo 'test content' > test.txt
101 | $ echo 'more content' > more.txt
102 | $ git add *.txt
103 | $ git commit -m 'added two files'
104 | [master 8bd6d8b] added two files
105 |  2 files changed, 2 insertions(+), 0 deletions(-)
106 |  create mode 100644 more.txt
107 |  create mode 100644 test.txt
108 | $ ls
109 | README   hello.rb more.txt test.txt
110 | $ git checkout testing
111 | Switched to branch 'testing'
112 | $ ls
113 | README   hello.rb
114 | 
115 | 116 |

当我们切换到“测试”分支的时候,我们添加的新文件被移除了。切换回“master”分支的时候,它们有重新出现了。 117 |

118 | 119 |
120 | $ ls
121 | README   hello.rb
122 | $ git checkout master
123 | Switched to branch 'master'
124 | $ ls
125 | README   hello.rb more.txt test.txt
126 | 
127 | 128 |

129 | git checkout -b (branchname) 130 | 创建新分支,并立即切换到它 131 |

132 | 133 |

134 | 通常情况下,你会更希望立即切换到新分支,从而在该分支中操作,然后当此分支的开发日趋稳定时, 135 | 将它合并到稳定版本的分支(例如“master”)中去。 136 | 执行 git branch newbranch; git checkout newbranch 也很简单, 137 | 不过 Git 还为你提供了快捷方式:git checkout -b newbranch。 138 |

139 | 140 |
141 | $ git branch
142 | * master
143 | $ ls
144 | README   hello.rb more.txt test.txt
145 | $ git checkout -b removals
146 | Switched to a new branch 'removals'
147 | $ git rm more.txt 
148 | rm 'more.txt'
149 | $ git rm test.txt 
150 | rm 'test.txt'
151 | $ ls
152 | README   hello.rb
153 | $ git commit -am 'removed useless files'
154 | [removals 8f7c949] removed useless files
155 |  2 files changed, 0 insertions(+), 2 deletions(-)
156 |  delete mode 100644 more.txt
157 |  delete mode 100644 test.txt
158 | $ git checkout master
159 | Switched to branch 'master'
160 | $ ls
161 | README   hello.rb more.txt test.txt
162 | 
163 | 164 |

如你所见,我们创建了一个分支,在该分支的上下文中移除了一些文件,然后切换回我们的主分支,那些文件又回来了。 165 | 使用分支将工作切分开来,从而让我们能够在不同上下文中做事,并来回切换。 166 |

167 | 168 |

169 | 创建新分支,在其中完成一部分工作,完成之后将它合并到主分支并删除。你会觉得这很方便,因为这么做很快很容易。 170 | 如此,当你觉得这部分工作并不靠谱,舍弃它很容易。并且,如果你必须回到稳定分支做些事情, 171 | 也可以很方便地这个独立分支的工作先丢在一边,完成要事之后再切换回来。 172 |

173 | 174 |

175 | git branch -d (branchname) 176 | 删除分支 177 |

178 | 179 |

假设我们要删除一个分支(比如上例中的“testing”分支,该分支没啥特殊的内容了), 180 | 可以执行 git branch -d (branch) 把它删掉。 181 |

182 | 183 |
184 | $ git branch
185 | * master
186 |   testing
187 | $ git branch -d testing
188 | Deleted branch testing (was 78b2670).
189 | $ git branch
190 | * master
191 | 
192 | 193 |

194 | 简而言之 使用 git branch 列出现有的分支、创建新分支以及删除不必要或者已合并的分支。 195 |

196 | 197 |
198 |
199 | 200 |
201 |

202 | 203 | docs   204 | book 205 | 206 | git merge 207 | 将分支合并到你的当前分支 208 |

209 | 210 |
211 |

一旦某分支有了独立内容,你终究会希望将它合并回到你的主分支。 212 | 你可以使用 git merge 命令将任何分支合并到当前分支中去。 213 | 我们那上例中的“removals”分支为例。假设我们创建了一个分支,移除了一些文件,并将它提交到该分支, 214 | 其实该分支是与我们的主分支(也就是“master”)独立开来的。 215 | 要想将这些移除操作包含在主分支中,你可以将“removals”分支合并回去。 216 |

217 | 218 |
219 | $ git branch
220 | * master
221 |   removals
222 | $ ls
223 | README   hello.rb more.txt test.txt
224 | $ git merge removals
225 | Updating 8bd6d8b..8f7c949
226 | Fast-forward
227 |  more.txt |    1 -
228 |  test.txt |    1 -
229 |  2 files changed, 0 insertions(+), 2 deletions(-)
230 |  delete mode 100644 more.txt
231 |  delete mode 100644 test.txt
232 | $ ls
233 | README   hello.rb
234 | 
235 | 236 |

237 | 更多复杂合并 238 |

239 | 240 |

当然,合并并不仅仅是简单的文件添加、移除的操作,Git 也会合并修改 —— 事实上,它很会合并修改。 241 | 举例,我们看看在某分支中编辑某个文件,然后在另一个分支中把它的名字改掉再做些修改, 242 | 最后将这俩分支合并起来。你觉得会变成一坨 shi?我们试试看。 243 |

244 | 245 |
246 | $ git branch
247 | * master
248 | $ cat hello.rb 
249 | class HelloWorld
250 |   def self.hello
251 |     puts "Hello World"
252 |   end
253 | end
254 | 
255 | HelloWorld.hello
256 | 
257 | 258 |

首先,我们创建一个叫做“change_class”的分支,切换过去,从而将重命名类等操作独立出来。我们将类名从 “HelloWorld” 改为 “HiWorld”。 259 |

260 | 261 |
262 | $ git checkout -b change_class
263 | M hello.rb
264 | Switched to a new branch 'change_class'
265 | $ vim hello.rb 
266 | $ head -1 hello.rb 
267 | class HiWorld
268 | $ git commit -am 'changed the class name'
269 | [change_class 3467b0a] changed the class name
270 |  1 files changed, 2 insertions(+), 4 deletions(-)
271 | 
272 | 273 |

然后,将重命名类操作提交到 “change_class” 分支中。 274 | 现在,假如切换回 “master” 分支我们可以看到类名恢复到了我们切换到 “change_class” 分支之前的样子。 275 | 现在,再做些修改(即代码中的输出),同时将文件名从 hello.rb 改为 ruby.rb。 276 |

277 | 278 |
279 | $ git checkout master
280 | Switched to branch 'master'
281 | $ git mv hello.rb ruby.rb
282 | $ vim ruby.rb 
283 | $ git diff
284 | diff --git a/ruby.rb b/ruby.rb
285 | index 2aabb6e..bf64b17 100644
286 | --- a/ruby.rb
287 | +++ b/ruby.rb
288 | @@ -1,7 +1,7 @@
289 |  class HelloWorld
290 | 
291 |    def self.hello
292 | -    puts "Hello World"
293 | +    puts "Hello World from Ruby"
294 |    end
295 | 
296 |  end
297 | $ git commit -am 'added from ruby'
298 | [master b7ae93b] added from ruby
299 |  1 files changed, 1 insertions(+), 1 deletions(-)
300 |  rename hello.rb => ruby.rb (65%)
301 | 
302 | 303 |

现在这些改变已经记录到我的 “master” 分支了。请注意,这里类名还是 “HelloWorld”,而不是 “HiWorld”。 304 | 然后我想将类名的改变合并过来,我把 “change_class” 分支合并过来就行了。 305 | 但是,我已经将文件名都改掉了,Git 知道该怎么办么? 306 |

307 | 308 |
309 | $ git branch
310 |   change_class
311 | * master
312 | $ git merge change_class
313 | Renaming hello.rb => ruby.rb
314 | Auto-merging ruby.rb
315 | Merge made by recursive.
316 |  ruby.rb |    6 ++----
317 |  1 files changed, 2 insertions(+), 4 deletions(-)
318 | $ cat ruby.rb
319 | class HiWorld
320 |   def self.hello
321 |     puts "Hello World from Ruby"
322 |   end
323 | end
324 | 
325 | HiWorld.hello
326 | 
327 | 328 |

不错,它就是发现了。请注意,在这部操作,我没有遇到合并冲突,并且文件已经重命名、类名也换掉了。挺酷。 329 |

330 | 331 |

332 | 合并冲突 333 |

334 | 335 |

那么,Git 合并很有魔力,我们再也不用处理合并冲突了,对吗?不太确切。 336 | 不同分支中修改了相同区块的代码,电脑自己猜不透神马的情况下,冲突就摆在我们面前了。 337 | 我们看看两个分支中改了同一行代码的例子。 338 |

339 | 340 |
341 | $ git branch
342 | * master
343 | $ git checkout -b fix_readme
344 | Switched to a new branch 'fix_readme'
345 | $ vim README 
346 | $ git commit -am 'fixed readme title'
347 | [fix_readme 3ac015d] fixed readme title
348 |  1 files changed, 1 insertions(+), 1 deletions(-)
349 | 
350 | 351 |

我们在某分支中修改了 README 文件中的一行,并提交了。我们再在 “master” 分支中对同个文件的同一行内容作不同的修改。 352 |

353 | 354 |
355 | $ git checkout master
356 | Switched to branch 'master'
357 | $ vim README 
358 | $ git commit -am 'fixed readme title differently'
359 | [master 3cbb6aa] fixed readme title differently
360 |  1 files changed, 1 insertions(+), 1 deletions(-)
361 | 
362 | 363 |

有意思的来了 —— 我们将前一个分支合并到 “master” 分支,一个合并冲突就出现了。 364 |

365 | 366 |
367 | $ git merge fix_readme
368 | Auto-merging README
369 | CONFLICT (content): Merge conflict in README
370 | Automatic merge failed; fix conflicts and then commit the result.
371 | $ cat README 
372 | <<<<<<< HEAD
373 | Many Hello World Examples
374 | =======
375 | Hello World Lang Examples
376 | >>>>>>> fix_readme
377 | 
378 | This project has examples of hello world in
379 | nearly every programming language.
380 | 
381 | 382 |

你可以看到,Git 在产生合并冲突的地方插入了标准的与 Subversion 很像的合并冲突标记。 383 | 轮到我们去解决这些冲突了。在这里我们就手动把它解决。如果你要 Git 打开一个图形化的合并工具, 384 | 可以看看 git 合并工具 385 | (比如 kdiff3、emerge、p4merge 等)。 386 |

387 | 388 |
389 | $ vim README   here I'm fixing the conflict
390 | $ git diff
391 | diff --cc README
392 | index 9103e27,69cad1a..0000000
393 | --- a/README
394 | +++ b/README
395 | @@@ -1,4 -1,4 +1,4 @@@
396 | - Many Hello World Examples
397 |  -Hello World Lang Examples
398 | ++Many Hello World Lang Examples
399 | 
400 |   This project has examples of hello world in
401 | 
402 | 403 |

在 Git 中,处理合并冲突的时候有个很酷的提示。 404 | 如果你执行 git diff,就像我演示的这样,它会告诉你冲突的两方,和你是如何解决的。 405 | 现在是时候把它标记为已解决了。在 Git 中,我们可以用 git add —— 要告诉 Git 文件冲突已经解决,你必须把它写入缓存区。 406 |

407 | 408 |
409 | $ git status -s
410 | UU README
411 | $ git add README 
412 | $ git status -s
413 | M  README
414 | $ git commit 
415 | [master 8d585ea] Merge branch 'fix_readme'
416 | 
417 | 418 |

现在我们成功解决了合并中的冲突,并提交了结果 419 |

420 | 421 |

422 | 简而言之 使用 git merge 将另一个分支并入当前的分支中去。 423 | Git 会自动以最佳方式将两个不同快照中独特的工作合并到一个新快照中去。 424 |

425 | 426 |
427 |
428 | 429 |
430 |

431 | 432 | 文档   433 | 434 | 435 | git log 436 | 显示一个分支中提交的更改记录 437 |

438 | 439 |
440 | 441 |

到目前为止,我们已经提交快照到项目中,在不同的各自分离的上下文中切换, 442 | 但假如我们忘了自己是如何到目前这一步的那该怎么办?或者假如我们想知道此分支与彼分支到底有啥区别? 443 | Git 提供了一个告诉你使你达成当前快照的所有提交消息的工具,叫做 git log。 444 |

445 | 446 |

要理解日志(log)命令,你需要了解当执行 git commit 以存储一个快照的时候,都有啥信息被保存了。 447 | 除了文件详单、提交消息和提交者的信息,Git 还保存了你的此次提交所基于的快照。 448 | 也就是,假如你克隆了一个项目,你是在什么快照的基础上做的修改而得到新保存的快照的? 449 | 这有益于为项目进程提供上下文,使 Git 能够弄明白谁做了什么改动。 450 | 如果 Git 有你的快照所基于的快照的话,它就能自动判断你都改变了什么。而新提交所基于的提交,被称作新提交的“父亲”。 451 |

452 | 453 |

某分支的按时间排序的“父亲”列表,当你在该分支时,可以执行 git log 以查看。 454 | 例如,如果我们在本章中操作的 Hello World 项目中执行 git log,我们可以看到已提交的消息。 455 |

456 | 457 |
458 | $ git log
459 | commit 8d585ea6faf99facd39b55d6f6a3b3f481ad0d3d
460 | Merge: 3cbb6aa 3ac015d
461 | Author: Scott Chacon <schacon@gmail.com>
462 | Date:   Fri Jun 4 12:59:47 2010 +0200
463 | 
464 |     Merge branch 'fix_readme'
465 | 
466 |     Conflicts:
467 |         README
468 | 
469 | commit 3cbb6aae5c0cbd711c098e113ae436801371c95e
470 | Author: Scott Chacon <schacon@gmail.com>
471 | Date:   Fri Jun 4 12:58:53 2010 +0200
472 | 
473 |     fixed readme title differently
474 | 
475 | commit 3ac015da8ade34d4c7ebeffa2053fcac33fb495b
476 | Author: Scott Chacon <schacon@gmail.com>
477 | Date:   Fri Jun 4 12:58:36 2010 +0200
478 | 
479 |     fixed readme title
480 | 
481 | commit 558151a95567ba4181bab5746bc8f34bd87143d6
482 | Merge: b7ae93b 3467b0a
483 | Author: Scott Chacon <schacon@gmail.com>
484 | Date:   Fri Jun 4 12:37:05 2010 +0200
485 | 
486 |     Merge branch 'change_class'
487 | ...
488 | 
489 | 490 |

我们可以用 --oneline 选项来查看历史记录的紧凑简洁的版本。 491 |

492 | 493 |
494 | $ git log --oneline
495 | 8d585ea Merge branch 'fix_readme'
496 | 3cbb6aa fixed readme title differently
497 | 3ac015d fixed readme title
498 | 558151a Merge branch 'change_class'
499 | b7ae93b added from ruby
500 | 3467b0a changed the class name
501 | 17f4acf first commit
502 | 
503 | 504 |

505 | 这告诉我们的是,此项目的开发历史。如果提交消息描述性很好,这就能为我们提供关于有啥改动被应用、或者影响了当前快照的状态、以及这快照里头都有啥。 506 |

507 | 508 |

我们还可以用它的十分有帮助的 --graph 选项,查看历史中什么时候出现了分支、合并。以下为相同的命令,开启了拓扑图选项: 509 |

510 | 511 |
512 | $ git log --oneline --graph
513 | *   8d585ea Merge branch 'fix_readme'
514 | |\
515 | | * 3ac015d fixed readme title
516 | * | 3cbb6aa fixed readme title differently
517 | |/
518 | *   558151a Merge branch 'change_class'
519 | |\
520 | | * 3467b0a changed the class name
521 | * | b7ae93b added from ruby
522 | |/
523 | * 17f4acf first commit
524 | 
525 | 526 |

现在我们可以更清楚明了地看到何时工作分叉、又何时归并。 527 | 这对查看发生了什么、应用了什么改变很有帮助,并且极大地帮助你管理你的分支。 528 | 让我们创建一个分支,在里头做些事情,然后切回到主分支,也做点事情,然后看看 log 529 | 命令是如何帮助我们理清这俩分支上都发生了啥的。 530 |

531 | 532 |

首先我们创建一个分支,来添加 Erlang 编程语言的 Hello World 示例 —— 533 | 我们想要在一个分支里头做这个,以避免让可能还不能工作的代码弄乱我们的稳定分支。 534 | 这样就可以切来切去,片叶不沾身。 535 |

536 | 537 |
538 | $ git checkout -b erlang
539 | Switched to a new branch 'erlang'
540 | $ vim erlang_hw.erl
541 | $ git add erlang_hw.erl 
542 | $ git commit -m 'added erlang'
543 | [erlang ab5ab4c] added erlang
544 |  1 files changed, 5 insertions(+), 0 deletions(-)
545 |  create mode 100644 erlang_hw.erl
546 | 
547 | 548 |

由于我们玩函数式编程很开心,以至于沉迷其中,又在“erlang”分支中添加了一个 Haskell 的示例程序。 549 |

550 | 551 |
552 | $ vim haskell.hs
553 | $ git add haskell.hs 
554 | $ git commit -m 'added haskell'
555 | [erlang 1834130] added haskell
556 |  1 files changed, 4 insertions(+), 0 deletions(-)
557 |  create mode 100644 haskell.hs
558 | 
559 | 560 |

最后,我们决定还是把 Ruby 程序的类名改回原先的样子。与其创建另一个分支,我们可以返回主分支,改变它,然后直接提交。 561 |

562 | 563 |
564 | $ git checkout master
565 | Switched to branch 'master'
566 | $ ls
567 | README  ruby.rb
568 | $ vim ruby.rb 
569 | $ git commit -am 'reverted to old class name'
570 | [master 594f90b] reverted to old class name
571 |  1 files changed, 2 insertions(+), 2 deletions(-)
572 | 
573 | 574 |

现在假设我们有段时间不做这个项目了,我们做别的去了。 575 | 当我们回来的时候,我们想知道“erlang”分支都是啥,而主分支的进度又是怎样。 576 | 仅仅看分支的名字,我们是无从知道自己还在里面有 Haskell 的改动的,但是用 git log 我们就可以。 577 | 如果你在命令行中提供一个分支名字,它就会显示该分支历史中“可及”的提交,即从该分支创立起可追溯的影响了最终的快照的提交。 578 |

579 | 580 |
581 | $ git log --oneline erlang
582 | 1834130 added haskell
583 | ab5ab4c added erlang
584 | 8d585ea Merge branch 'fix_readme'
585 | 3cbb6aa fixed readme title differently
586 | 3ac015d fixed readme title
587 | 558151a Merge branch 'change_class'
588 | b7ae93b added from ruby
589 | 3467b0a changed the class name
590 | 17f4acf first commit
591 | 
592 | 593 |

如此,我们很容易就看到分支里头还包括了 Haskell 代码(高亮显示了)。 594 | 更酷的是,我们很容易地告诉 Git,我们只对某个分支中可及的提交感兴趣。换句话说,某分支中与其他分支相比唯一的提交。 595 |

596 | 597 |

在此例中,如果我们想要合并“erlang”分支,我们需要看当合并的时候,都有啥提交会作用到我们的快照上去。 598 | 我们告诉 Git 的方式是,在不想要看到的分支前放一个 ^。 599 | 例如,如果我们想要看“erlang”分支中但不在主分支中的提交,我们可以用 erlang ^master,或者反之。 600 |

601 | 602 |
603 | $ git log --oneline erlang ^master
604 | 1834130 added haskell
605 | ab5ab4c added erlang
606 | $ git log --oneline master ^erlang
607 | 594f90b reverted to old class name
608 | 
609 | 610 |

这为我们提供了一个良好的、简易的分支管理工具。它使我们能够非常容易地查看对某个分支唯一的提交,从而知道我们缺少什么,以及当我们要合并时,会有什么被合并进去。 611 |

612 | 613 |

614 | 简而言之 使用 git log 列出促成当前分支目前的快照的提交历史记录。这使你能够看到项目是如何到达现在的状况的。 615 |

616 | 617 |
618 |
619 | 620 |
621 |

622 | 623 | 文档   624 | 625 | 626 | git tag 627 | 给历史记录中的某个重要的一点打上标签 628 |

629 | 630 |
631 | 632 |

633 | 如果你达到一个重要的阶段,并希望永远记住那个特别的提交快照,你可以使用 git tag 给它打上标签。 634 | 该 tag 命令基本上会给该特殊提交打上永久的书签,从而使你在将来能够用它与其他提交比较。 635 | 通常,你会在切取一个发布版本或者交付一些东西的时候打个标签。 636 |

637 | 638 |

比如说,我们想为我们的 Hello World 项目发布一个“1.0”版本。 639 | 我们可以用 git tag -a v1.0 命令给最新一次提交打上(HEAD)“v1.0”的标签。 640 | -a 选项意为“创建一个带注解的标签”,从而使你为标签添加注解。绝大部分时候都会这么做的。 641 | 不用 -a 选项也可以执行的,但它不会记录这标签是啥时候打的,谁打的,也不会让你添加个标签的注解。 642 | 我推荐一直创建带注解的标签。 643 |

644 | 645 |
646 | $ git tag -a v1.0 
647 | 
648 | 649 |

当你执行 git tag -a 命令时,Git 会打开你的编辑器,让你写一句标签注解,就像你给提交写注解一样。 650 |

651 | 652 |

现在,注意当我们执行 git log --decorate 时,我们可以看到我们的标签了: 653 |

654 | 655 |
656 | $ git log --oneline --decorate --graph
657 | * 594f90b (HEAD, tag: v1.0, master) reverted to old class name
658 | *   8d585ea Merge branch 'fix_readme'
659 | |\
660 | | * 3ac015d (fix_readme) fixed readme title
661 | * | 3cbb6aa fixed readme title differently
662 | |/
663 | *   558151a Merge branch 'change_class'
664 | |\
665 | | * 3467b0a changed the class name
666 | * | b7ae93b added from ruby
667 | |/
668 | * 17f4acf first commit
669 | 
670 | 671 |

如果我们有新提交,该标签依然会待在该提交的边上,所以我们已经给那个特定快照永久打上标签,并且能够将它与未来的快照做比较。 672 |

673 | 674 |

不过我们并不需要给当前提交打标签。如果我们忘了给某个提交打标签,又将它发布了,我们可以给它追加标签。 675 | 在相同的命令末尾加上提交的 SHA,执行,就可以了。 676 | 例如,假设我们发布了提交 558151a(几个提交之前的事情了),但是那时候忘了给它打标签。 677 | 我们现在也可以:

678 | 679 |
680 | $ git tag -a v0.9 558151a
681 | $ git log --oneline --decorate --graph
682 | * 594f90b (HEAD, tag: v1.0, master) reverted to old class name
683 | *   8d585ea Merge branch 'fix_readme'
684 | |\
685 | | * 3ac015d (fix_readme) fixed readme title
686 | * | 3cbb6aa fixed readme title differently
687 | |/
688 | *   558151a (tag: v0.9) Merge branch 'change_class'
689 | |\
690 | | * 3467b0a changed the class name
691 | * | b7ae93b added from ruby
692 | |/
693 | * 17f4acf first commit
694 | 
695 | 696 |
697 |
698 | 699 |

到 分享与更新项目 »

700 | -------------------------------------------------------------------------------- /zh/cookbook.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: zh_reference 3 | --- 4 |
5 |

Git Cookbook

6 |
    7 |
  • Revert a file
  • 8 |
  • Recover a lost branch
  • 9 |
  • Contribute to a project on GitHub
  • 10 |
  • Undo a merge
  • 11 |
12 |
13 | -------------------------------------------------------------------------------- /zh/creating/index.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: zh_reference 3 | --- 4 | 5 |
6 |

获取与创建项目

7 |
8 |

9 | 你得先有一个 Git 仓库,才能用它进行操作。仓库是 Git 存放你要保存的快照的数据的地方。 10 |

11 | 12 |

拥有一个 Git 仓库的途径有两种。在已有的目录中,初始化一个新的,其一。 13 | 比如一个新的项目,或者一个已存在的项目,但该项目尚未有版本控制。如果你想要复制一份别人的项目, 14 | 或者与别人合作某个项目,也可以从一个公开的 Git 仓库克隆,其二。本章将对两者都做介绍。 15 |

16 |
17 |
18 | 19 |
20 |

21 | 22 | 文档   23 | 24 | 25 | git init 26 | 将一个目录初始化为 Git 仓库 27 |

28 | 29 |
30 |

在目录中执行 git init,就可以创建一个 Git 仓库了。比如,我们恰好有个目录,里头有些许文件,如下: 31 |

32 |
 33 | $ cd konnichiwa
 34 | $ ls
 35 | README   hello.rb
 36 | 
37 | 38 |

39 | 在这个项目里头,我们会用各种编程语言写 "Hello World" 实例。 40 | 到目前为止,我们只有 Ruby 的,不过,这才刚上路嘛。为了开始用 Git 对这个项目作版本控制,我们执行一下 git init。 41 |

42 | 43 |
 44 | $ git init
 45 | Initialized empty Git repository in /opt/konnichiwa/.git/
 46 | # 在 /opt/konnichiwa/.git 目录初始化空 Git 仓库完毕。
 47 | 
48 | 49 |

现在你可以看到在你的项目目录中有个 .git 的子目录。 50 | 这就是你的 Git 仓库了,所有有关你的此项目的快照数据都存放在这里。 51 |

52 | 53 |
 54 | $ ls -a
 55 | .        ..       .git     README   hello.rb
 56 | 
57 | 58 |

恭喜,现在你就有了一个 Git 仓库的架子,可以开始快照你的项目了。 59 |

60 | 61 |

62 | 简而言之,用 git init 来在目录中创建新的 Git 仓库。 63 | 你可以在任何时候、任何目录中这么做,完全是本地化的。 64 |

65 | 66 |
67 |
68 | 69 |
70 |

71 | 72 | 文档   73 | 74 | 75 | git clone 76 | 复制一个 Git 仓库,以上下其手 77 |

78 |
79 |

如果你需要与他人合作一个项目,或者想要复制一个项目,看看代码,你就可以克隆那个项目。 80 | 执行 git clone [url],[url] 为你想要复制的项目,就可以了。 81 |

82 | 83 |
 84 | $ git clone git://github.com/schacon/simplegit.git
 85 | Initialized empty Git repository in /private/tmp/simplegit/.git/
 86 | remote: Counting objects: 100, done.
 87 | remote: Compressing objects: 100% (86/86), done.
 88 | remote: Total 100 (delta 35), reused 0 (delta 0)
 89 | Receiving objects: 100% (100/100), 9.51 KiB, done.
 90 | Resolving deltas: 100% (35/35), done.
 91 | $ cd simplegit/
 92 | $ ls
 93 | README   Rakefile lib
 94 | 
95 | 96 |

上述操作将复制该项目的全部记录,让你本地拥有这些。并且该操作将拷贝该项目的主分支, 97 | 使你能够查看代码,或编辑、修改。进到该目录中,你会看到 .git 子目录。 98 | 所有的项目数据都存在那里。 99 |

100 | 101 |
102 | $ ls -a
103 | .        ..       .git     README   Rakefile lib
104 | $ cd .git
105 | $ ls
106 | HEAD        description info        packed-refs
107 | branches    hooks       logs        refs
108 | config      index       objects
109 | 
110 | 111 |

默认情况下,Git 会按照你提供的 URL 所指示的项目的名称创建你的本地项目目录。 112 | 通常就是该 URL 最后一个 / 之后的任何东西。如果你想要一个不一样的名字, 113 | 你可以在该命令后加上它,就在那个 URL 后面。 114 |

115 | 116 |

117 | 简而言之,使用 git clone 拷贝一个 Git 仓库到本地,让自己能够查看该项目,或者进行修改。 118 |

119 | 120 |
121 |
122 | 123 |

接下来:基本快照 »

124 | -------------------------------------------------------------------------------- /zh/images/snapshots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/git/git-reference/0de29ad3af4e179ddf8465c1ae6c28d5fca42167/zh/images/snapshots.png -------------------------------------------------------------------------------- /zh/index.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: zh_reference 3 | --- 4 |
5 |

Git 手册简介

6 |
7 |

8 | 本站为 Git 参考手册。目的是为学习与记忆 Git 使用中最重要、最普遍的命令提供快速翻阅。 9 | 这些命令以你可能需要的操作类型划分,并且将提供日常使用中需要的一些常用的命令以及参数。 10 |

11 |

12 | 每个章节都有到下一个章节的链接,所以本手册也可以当作一个入门指导。 13 | 每个页面还有一个深度 Git 文档阅读的链接,比如官方的使用手册页面或者 《Pro Git》 14 | 书中的相关章节,以便于你学习了解更多的 Git 命令。首先,我们要从如何以 Git 的思维方式管理源代码开始。 15 |

16 |
17 |
18 | 19 |
20 |

如何以 Git 的方式思考

21 |
22 |

23 | 懂得 Git,第一件重要的事情就是要知道它与 Subversion、Perforce 或者任何你用过的版本控制工具都有着很大的差别。 24 | 通常,忘掉你预想的版本控制方式,改以 Git 的方式思考,能够帮助你更好地学习 Git。 25 |

26 | 27 |

28 | 让我们从头开始。假设你正在设计一个新的源代码管理系统。在你使用某个工具之前,是如何完成基本的源码版本控制工作的呢? 29 | 十有八九,你只是在项目到达某些阶段的时候,对项目做一份拷贝。 30 |

31 | 32 |
 $ cp -R project project.bak 
33 | 34 |

35 | 这样,你就可以在事情变得一团糟的时候很方便的返回到之前的状态,或者通过对比当前的项目与之前的拷贝,看看自己在之后的工作中,都做了哪些修改。 36 |

37 | 38 |

39 | 如果你有点偏执,你可能会经常作上面说的事情,或许还会给项目拷贝加个日期: 40 |

41 | 42 |
 $ cp -R project project.2010-06-01.bak 
43 | 44 |

45 | 如此,你就有了一堆项目在各个阶段的快照,来作比较、查看。使用这种模式,你还可以有效地与人分享项目变更。 46 | 如果你会在项目到达一定阶段的时候给它打个包,丢到自己的网站上,那其他的开发者们,就能很方便地下载它,做点改动,并给你补丁回馈。 47 |

48 | 49 |
50 |  $ wget http://example.com/project.2010-06-01.zip
51 |  $ unzip project.2010-06-01.zip
52 |  $ cp -R project.2010-06-01 project-my-copy
53 |  $ cd project-my-copy
54 |  $ (做了某些修改)
55 |  $ diff project-my-copy project.2010-06-01 > change.patch
56 |  $ (通过E-mail发送修改补丁)
57 | 58 |

59 | 以此方式,原先的开发者就能将其他人的改动应用到他的项目中去,其他开发者也能了解你做的变更。其实这便是许多开源项目采用过多年的协作方式。 60 |

61 | 62 |

63 | 这办法其实很好使,所以假设我们现在想要写个工具,让这个办法更快、更简单。 64 | 我们与其实现一个工具以记录每个文件的版本,可能不如去实现个工具以使创建、储存项目的快照更加方便,不用每次都去人肉作整个项目的拷贝。 65 |

66 | 67 |

68 | 这就是 Git 的精要所在。你通过 git commit告诉 Git 你想保存一份项目快照, 69 | Git 就会为你的项目中的各个文件的当前状态存一份记录。之后,绝大部分的 Git 命令都围绕这些记录展开。 70 | 比如查看它们的区别(diff),提取它们的内容,等等。 71 |

72 | 73 |
74 | 75 |

76 | 如果你将 Git 看作一个排序、对比以及合并项目更新的工具,那就容易理解状况和正确做事了。 77 |

78 | 79 |
80 |
81 | 82 |

接下来:获取与创建项目»

83 | -------------------------------------------------------------------------------- /zh/inspect/index.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: zh_reference 3 | --- 4 | 5 |
6 |

7 | 8 | 9 | 10 | 检查与比较 11 |

12 |
13 |

14 | 现在你有了一堆分支,短期的主题、长期的特性或者其它。怎样追踪他们呢? 15 | Git 有一组工具,可以帮助你弄明白工作是在哪儿完成的,两个分支间的区别是啥,等等。 16 |

17 | 18 |

19 | 简而言之 执行 git log 找到你的项目历史中的特定提交 —— 20 | 按作者、日期、内容或者历史记录。执行 git diff 比较历史记录中的两个不同的点 —— 21 | 通常是为了看看两个分支有啥区别,或者从某个版本到另一个版本,你的软件都有啥变化。 22 |

23 |
24 |
25 | 26 |
27 |

28 | 29 | 文档   30 | 书k 31 | 32 | git log 33 | 过滤你的提交历史记录 34 |

35 | 36 |
37 |

38 | 通过查看分支中另一分支看不到的提交记录,我们已经看到如何用 git log 来比较分支。 39 | (如果你不记得了,它看起来是这样的:git log branchA ^branchB)。 40 | 而且,你也可以用 git log 去寻找特定的提交。 41 | 在此,我们会看到一些更广为使用的 git log 选项,不过哪有很多。 42 | 完整的清单可以看看官方文档。 43 |

44 | 45 |

46 | git log --author 47 | 只寻找某个特定作者的提交 48 |

49 | 50 |

51 | 要过滤你的提交历史,只寻找某个特定作者的提交,你可以使用 --author 选项。 52 | 例如,比方说我们要找 Git 源码中 Linus 提交的部分。 53 | 我们可以执行类似 git log --author=Linus 的命令。 54 | 这个查找是大小写敏感的,并且也会检索电子邮箱地址。 55 | 我在此例中使用 -[number] 选项,以限制结果为最近 [number] 次的提交。 56 |

57 | 58 |
 59 | $ git log --author=Linus --oneline -5
 60 | 81b50f3 Move 'builtin-*' into a 'builtin/' subdirectory
 61 | 3bb7256 make "index-pack" a built-in
 62 | 377d027 make "git pack-redundant" a built-in
 63 | b532581 make "git unpack-file" a built-in
 64 | 112dd51 make "mktag" a built-in
 65 | 
66 | 67 |

68 | git log --since --before 69 | 根据日期过滤提交记录 70 |

71 | 72 |

73 | 如果你要指定一个你感兴趣的日期范围以过滤你的提交,可以执行几个选项 —— 74 | 我用 --since--before,但是你也可以用 --until--after。 75 | 例如,如果我要看 Git 项目中三周前且在四月十八日之后的所有提交,我可以执行这个(我还用了 --no-merges 选项以隐藏合并提交): 76 |

77 | 78 |
 79 | $ git log --oneline --before={3.weeks.ago} --after={2010-04-18} --no-merges
 80 | 5469e2d Git 1.7.1-rc2
 81 | d43427d Documentation/remote-helpers: Fix typos and improve language
 82 | 272a36b Fixup: Second argument may be any arbitrary string
 83 | b6c8d2d Documentation/remote-helpers: Add invocation section
 84 | 5ce4f4e Documentation/urls: Rewrite to accomodate transport::address
 85 | 00b84e9 Documentation/remote-helpers: Rewrite description
 86 | 03aa87e Documentation: Describe other situations where -z affects git diff
 87 | 77bc694 rebase-interactive: silence warning when no commits rewritten
 88 | 636db2c t3301: add tests to use --format="%N"
 89 | 
90 | 91 |

92 | git log --grep 93 | 根据提交注释过滤提交记录 94 |

95 | 96 |

97 | 你或许还想根据提交注释中的某个特定短语查找提交记录。可以用 --grep 选项。 98 | 比如说我知道有个提交是有关使用 P4EDITOR 环境变量,又想回忆起那个改动是啥样子的 —— 我可以用 --grep 选项找到该提交。 99 |

100 | 101 |
102 | $ git log --grep=P4EDITOR --no-merges
103 | commit 82cea9ffb1c4677155e3e2996d76542502611370
104 | Author: Shawn Bohrer
105 | Date:   Wed Mar 12 19:03:24 2008 -0500
106 | 
107 |     git-p4: Use P4EDITOR environment variable when set
108 | 
109 |     Perforce allows you to set the P4EDITOR environment variable to your
110 |     preferred editor for use in perforce.  Since we are displaying a
111 |     perforce changelog to the user we should use it when it is defined.
112 | 
113 |     Signed-off-by: Shawn Bohrer <shawn.bohrer@gmail.com>
114 |     Signed-off-by: Simon Hausmann <simon@lst.de>
115 | 
116 | 117 |

118 | Git 会对所有的 --grep--author 参数作逻辑或。 119 | 如果你用 --grep--author 时,想看的是某人写作的并且有某个特殊的注释内容的提交记录, 120 | 你需要加上 --all-match 选项。 121 | 在这些例子中,我会用上 --format 选项,这样我们就可以看到每个提交的作者是谁了。 122 |

123 | 124 |

125 | 如果我查找注释内容含有 “p4 depo”的提交,我得到了三个提交: 126 |

127 | 128 |
129 | $ git log --grep="p4 depo" --format="%h %an %s"
130 | ee4fd1a Junio C Hamano Merge branch 'master' of git://repo.or.cz/git/fastimport
131 | da4a660 Benjamin Sergeant git-p4 fails when cloning a p4 depo.
132 | 1cd5738 Simon Hausmann Make incremental imports easier to use by storing the p4 d
133 | 
134 | 135 |

136 | 如果我加上 --author=Hausmann 参数,与进一步过滤上述结果到 Simon 的唯一提交相反, 137 | 它会告诉我所有 Simon 的提交,或者注释中有“p4 demo”的提交: 138 |

139 | 140 |
141 | $ git log --grep="p4 depo" --format="%h %an %s" --author="Hausmann"
142 | cdc7e38 Simon Hausmann Make it possible to abort the submission of a change to Pe
143 | f5f7e4a Simon Hausmann Clean up the git-p4 documentation
144 | 30b5940 Simon Hausmann git-p4: Fix import of changesets with file deletions
145 | 4c750c0 Simon Hausmann git-p4: git-p4 submit cleanups.
146 | 0e36f2d Simon Hausmann git-p4: Removed git-p4 submit --direct.
147 | edae1e2 Simon Hausmann git-p4: Clean up git-p4 submit's log message handling.
148 | 4b61b5c Simon Hausmann git-p4: Remove --log-substitutions feature.
149 | 36ee4ee Simon Hausmann git-p4: Ensure the working directory and the index are cle
150 | e96e400 Simon Hausmann git-p4: Fix submit user-interface.
151 | 38f9f5e Simon Hausmann git-p4: Fix direct import from perforce after fetching cha
152 | 2094714 Simon Hausmann git-p4: When skipping a patch as part of "git-p4 submit" m
153 | 1ca3d71 Simon Hausmann git-p4: Added support for automatically importing newly ap
154 | ...
155 | 
156 | 157 |

158 | 不过,如果加上 --all-match,结果就是我想要的了: 159 |

160 | 161 |
162 | $ git log --grep="p4 depo" --format="%h %an %s" --author="Hausmann" --all-match
163 | 1cd5738 Simon Hausmann Make incremental imports easier to use by storing the p4 d
164 | 
165 | 166 |

167 | git log -S 168 | 依据所引入的差值过滤 169 |

170 | 171 |

172 | 如果你写的提交注释都极度糟糕怎么办?或者,如果你要找某个函数是何时引入的,某些变量是在哪里开始被使用的? 173 | 你可以告诉 Git 在每个提交之间的差值中查找特定字符串。 174 | 例如,如果我们想要找出哪个提交修改出了类似函数名“userformat_find_requirements”, 175 | 我们可以执行(注意在“-S”与你要找的东东之间没有“=”): 176 |

177 | 178 |
179 | $ git log -Suserformat_find_requirements
180 | commit 5b16360330822527eac1fa84131d185ff784c9fb
181 | Author: Johannes Gilger
182 | Date:   Tue Apr 13 22:31:12 2010 +0200
183 | 
184 |     pretty: Initialize notes if %N is used
185 | 
186 |     When using git log --pretty='%N' without an explicit --show-notes, git
187 |     would segfault. This patches fixes this behaviour by loading the needed
188 |     notes datastructures if --pretty is used and the format contains %N.
189 |     When --pretty='%N' is used together with --no-notes, %N won't be
190 |     expanded.
191 | 
192 |     This is an extension to a proposed patch by Jeff King.
193 | 
194 |     Signed-off-by: Johannes Gilger
195 |     Signed-off-by: Junio C Hamano
196 | 
197 | 198 |

199 | git log -p 200 | 显示每个提交引入的补丁 201 |

202 | 203 |

204 | 每个提交都是项目的一个快照。由于每个提交都记录它所基于的快照,Git 能够经常对它们求差值,并以补丁形式向你展示。 205 | 这意味着,对任意提交,你都可以获取该提交给项目引入补丁。 206 | 你可以用 git show [SHA] 加上某个特定的提交 SHA 获取,或者执行 git log -p, 207 | 它会告诉 Git 输出每个提交之后的补丁。这是个总结某一分支或者两个提交之间都发生了神马的好途径。 208 |

209 | 210 |
211 | $ git log -p --no-merges -2
212 | commit 594f90bdee4faf063ad07a4a6f503fdead3ef606
213 | Author: Scott Chacon <schacon@gmail.com>
214 | Date:   Fri Jun 4 15:46:55 2010 +0200
215 | 
216 |     reverted to old class name
217 | 
218 | diff --git a/ruby.rb b/ruby.rb
219 | index bb86f00..192151c 100644
220 | --- a/ruby.rb
221 | +++ b/ruby.rb
222 | @@ -1,7 +1,7 @@
223 | -class HiWorld
224 | +class HelloWorld
225 |    def self.hello
226 |      puts "Hello World from Ruby"
227 |    end
228 |  end
229 | 
230 | -HiWorld.hello
231 | +HelloWorld.hello
232 | 
233 | commit 3cbb6aae5c0cbd711c098e113ae436801371c95e
234 | Author: Scott Chacon <schacon@gmail.com>
235 | Date:   Fri Jun 4 12:58:53 2010 +0200
236 | 
237 |     fixed readme title differently
238 | 
239 | diff --git a/README b/README
240 | index d053cc8..9103e27 100644
241 | --- a/README
242 | +++ b/README
243 | @@ -1,4 +1,4 @@
244 | -Hello World Examples
245 | +Many Hello World Examples
246 |  ======================
247 | 
248 |  This project has examples of hello world in
249 | 
250 | 251 |

252 | 这是个总结改动,以及合并或发布之前重审一系列提交的好方式。 253 |

254 | 255 |

256 | git log --stat 257 | 显示每个提交引入的改动的差值统计 258 |

259 | 260 |

261 | 如果 -p 选项对你来说太详细了,你可以用 --stat 总结这些改动。 262 | 这是不用 -p,而用 --stat 选项时,同一份日志的输出。 263 |

264 | 265 |
266 | $ git log --stat --no-merges -2
267 | commit 594f90bdee4faf063ad07a4a6f503fdead3ef606
268 | Author: Scott Chacon <schacon@gmail.com>
269 | Date:   Fri Jun 4 15:46:55 2010 +0200
270 | 
271 |     reverted to old class name
272 | 
273 |  ruby.rb |    4 ++--
274 |  1 files changed, 2 insertions(+), 2 deletions(-)
275 | 
276 | commit 3cbb6aae5c0cbd711c098e113ae436801371c95e
277 | Author: Scott Chacon <schacon@gmail.com>
278 | Date:   Fri Jun 4 12:58:53 2010 +0200
279 | 
280 |     fixed readme title differently
281 | 
282 |  README |    2 +-
283 |  1 files changed, 1 insertions(+), 1 deletions(-)
284 | 
285 | 286 |

287 | 同样的基本信息,但更紧凑 —— 它仍然让你看到相对改动,和改动了哪些文件。 288 |

289 | 290 |
291 |
292 | 293 |
294 |

295 | 296 | 文档   297 | 298 | 299 | git diff 300 | 301 |

302 | 303 |
304 | 305 |

306 | 最后,要查看两个提交快照的绝对改动,你可以用 git diff 命令。 307 | 这在两个主要情况中广为使用 —— 查看两个分支彼此之间的差值,和查看自发布或者某个旧历史点之后都有啥变了。让我们看看这俩情况。 308 |

309 | 310 |

311 | 你仅需执行 git diff [version](或者你给该发布打的任何标签)就可以查看自最近发布之后的改动。 312 | 例如,如果我们想要看看自 v0.9 发布之后我们的项目改变了啥,我们可以执行 git diff v0.9 313 |

314 | 315 |
316 | $ git diff v0.9
317 | diff --git a/README b/README
318 | index d053cc8..d4173d5 100644
319 | --- a/README
320 | +++ b/README
321 | @@ -1,4 +1,4 @@
322 | -Hello World Examples
323 | +Many Hello World Lang Examples
324 |  ======================
325 | 
326 |  This project has examples of hello world in
327 | diff --git a/ruby.rb b/ruby.rb
328 | index bb86f00..192151c 100644
329 | --- a/ruby.rb
330 | +++ b/ruby.rb
331 | @@ -1,7 +1,7 @@
332 | -class HiWorld
333 | +class HelloWorld
334 |    def self.hello
335 |      puts "Hello World from Ruby"
336 |    end
337 |  end
338 | 
339 | -HiWorld.hello
340 | +HelloWorld.hello
341 | 
342 | 343 |

344 | 正如 git log,你可以给它加上 --stat 参数。 345 |

346 | 347 |
348 | $ git diff v0.9 --stat
349 |  README  |    2 +-
350 |  ruby.rb |    4 ++--
351 |  2 files changed, 3 insertions(+), 3 deletions(-)
352 | 
353 | 354 |

355 | 要比较两个不同的分支,你可以执行类似 git diff branchA branchB 的命令。 356 | 不过它的问题在于它会完完全全按你说的作 —— 它会直接给你个补丁文件,该补丁能够将甲分支的最新快照变成乙分支的最新快照的样子。 357 | 这意味着如果两个分支已经产生分歧 —— 奔往两个不同方向了 —— 它会移除甲分支中引入的所有工作,然后累加乙分支中的所有工作。 358 | 这大概不是你要的吧 —— 你想要不在甲分支中的乙分支的改动。所以你真的需要的是两个分支叉开去时,和最新的乙分支的差别。 359 | 所以,如果我们的历史记录看起来像这样: 360 |

361 | 362 |
363 | $ git log --graph --oneline --decorate --all
364 | * 594f90b (HEAD, tag: v1.0, master) reverted to old class name
365 | | * 1834130 (erlang) added haskell
366 | | * ab5ab4c added erlang
367 | |/
368 | *   8d585ea Merge branch 'fix_readme'
369 | ...
370 | 
371 | 372 |

373 | 并且,我们想要看“erlang”分支与主分支相比的查别。执行 git diff master erlang 会给我们错误的结果。 374 |

375 | 376 |
377 | $ git diff --stat master erlang
378 |  erlang_hw.erl |    5 +++++
379 |  haskell.hs    |    4 ++++
380 |  ruby.rb       |    4 ++--
381 |  3 files changed, 11 insertions(+), 2 deletions(-)
382 | 
383 | 384 |

385 | 你可以看到,它加上了 erlang 和 haskell 文件,这确实是我们在该分支中做的, 386 | 但是它同时恢复了我们在主分支中改动的 ruby 文件。我们真心想要的只是“erlang”分支中的改动(添加两个文件)。 387 | 我们可以通过求两个分支分歧时的共同提交与该分支的差值得到想要的结果: 388 |

389 | 390 |
391 | $ git diff --stat 8d585ea erlang
392 |  erlang_hw.erl |    5 +++++
393 |  haskell.hs    |    4 ++++
394 |  2 files changed, 9 insertions(+), 0 deletions(-)
395 | 
396 | 397 |

398 | 这才是我们在找的,但是我们可不想要每次都要找出两个分支分歧时的那次提交。 399 | 幸运的是,Git 为此提供了一个快捷方式。 400 | 如果你执行 git diff master...erlang(在分支名之间有三个半角的点), 401 | Git 就会自动找出两个分支的共同提交(也被成为合并基础),并求差值。 402 |

403 | 404 |
405 | $ git diff --stat master erlang
406 |  erlang_hw.erl |    5 +++++
407 |  haskell.hs    |    4 ++++
408 |  ruby.rb       |    4 ++--
409 |  3 files changed, 11 insertions(+), 2 deletions(-)
410 | $ git diff --stat master...erlang
411 |  erlang_hw.erl |    5 +++++
412 |  haskell.hs    |    4 ++++
413 |  2 files changed, 9 insertions(+), 0 deletions(-)
414 | 
415 | 416 |

417 | 几乎每一次你要对比两个分支的时候,你都会想用三个点的语法,因为它通常会给你你想要的。 418 |

419 | 420 |

421 | 顺带提一句,你还可以让 Git 手工计算两次提交的合并基础(第一个共同的祖提交),即 git merge-base 命令: 422 |

423 | 424 |
425 | $ git merge-base master erlang
426 | 8d585ea6faf99facd39b55d6f6a3b3f481ad0d3d
427 | 
428 | 429 |

430 | 所以你执行下面这个也跟 git diff master...erlang 一样: 431 |

432 | 433 |
434 | $ git diff --stat $(git merge-base master erlang) erlang
435 |  erlang_hw.erl |    5 +++++
436 |  haskell.hs    |    4 ++++
437 |  2 files changed, 9 insertions(+), 0 deletions(-)
438 | 
439 | 440 |

当然,我会推荐简单点的那个。

441 | 442 | 443 |

444 | 简而言之 使用 git diff 查看某一分支自它偏离出来起与过去某一点之间项目的改动。 445 | 总是使用 git diff branchA...branchB 来查看 branchB 与 branchA 的相对差值,这会让事情简单点。 446 |

447 | 448 |
449 |
450 | 451 |

就是这样了! 请阅读 452 | 《Pro Git》 以获得更多信息。

453 | -------------------------------------------------------------------------------- /zh/remotes/index.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: zh_reference 3 | --- 4 | 5 |
6 |

7 | 8 | 9 | 10 | 分享与更新项目 11 |

12 |
13 |

14 | Git 并不像 Subversion 那样有个中心服务器。 15 | 目前为止所有的命令都是本地执行的,更新的只是本地的数据库。 16 | 要通过 Git 与其他开发者合作,你需要将数据放到一台其他开发者能够连接的服务器上。 17 | Git 实现此流程的方式是将你的数据与另一个仓库同步。在服务器与客户端之间并没有实质的区别 —— 18 | Git 仓库就是 Git 仓库,你可以很容易地在两者之间同步。 19 |

20 | 21 |

22 | 一旦你有了个 Git 仓库,不管它是在你自己的服务器上,或者是由 GitHub 之类的地方提供, 23 | 你都可以告诉 Git 推送你拥有的远端仓库还没有的数据,或者叫 Git 从别的仓库把差别取过来。 24 |

25 | 26 |

27 | 联网的时候你可以随时做这个,它并不需要对应一个 commit 或者别的什么。 28 | 一般你会本地提交几次,然后从你的项目克隆自的线上的共享仓库提取数据以保持最新,将新完成的合并到你完成的工作中去,然后推送你的改动会服务器。 29 |

30 | 31 |

32 | 简而言之 使用 git fetch 更新你的项目,使用 git push 分享你的改动。 33 | 你可以用 git remote 管理你的远程仓库。 34 |

35 |
36 |
37 | 38 |
39 |

40 | 41 | 文档   42 | 43 | 44 | git remote 45 | 罗列、添加和删除远端仓库别名 46 |

47 | 48 |
49 | 50 |

不像中心化的版本控制系统(客户端与服务端很不一样),Git 仓库基本上都是一致的,并且并可以同步他们。 51 | 这使得拥有多个远端仓库变得容易 —— 你可以拥有一些只读的仓库,另外的一些也可写的仓库。 52 |

53 | 54 |

55 | 当你需要与远端仓库同步的时候,不需要使用它详细的链接。Git 储存了你感兴趣的远端仓库的链接的别名或者昵称。 56 | 你可以使用 git remote 命令管理这个远端仓库列表。 57 |

58 | 59 |

60 | git remote 61 | 列出远端别名 62 |

63 | 64 |

65 | 如果没有任何参数,Git 会列出它存储的远端仓库别名了事。默认情况下,如果你的项目是克隆的(与本地创建一个新的相反), 66 | Git 会自动将你的项目克隆自的仓库添加到列表中,并取名“origin”。 67 | 如果你执行时加上 -v 参数,你还可以看到每个别名的实际链接地址。 68 |

69 | 70 |
 71 | $ git remote
 72 | origin
 73 | $ git remote -v
 74 | origin	git@github.com:github/git-reference.git (fetch)
 75 | origin	git@github.com:github/git-reference.git (push)
 76 | 
77 | 78 |

在此你看到了该链接两次,是因为 Git 允许你为每个远端仓库添加不同的推送与获取的链接,以备你读写时希望使用不同的协议。 79 |

80 | 81 |

82 | git remote add 83 | 为你的项目添加一个新的远端仓库 84 |

85 | 86 |

87 | 如果你希望分享一个本地创建的仓库,或者你想要获取别人的仓库中的贡献 —— 88 | 如果你想要以任何方式与一个新仓库沟通,最简单的方式通常就是把它添加为一个远端仓库。 89 | 执行 git remote add [alias] [url] 就可以。 90 | 此命令将 [url][alias] 的别名添加为本地的远端仓库。 91 |

92 | 93 |

94 | 例如,假设我们想要与整个世界分享我们的 Hello World 程序。 95 | 我们可以在一台服务器上创建一个新仓库(我以 GitHub 为例子)。 96 | 它应该会给你一个链接,在这里就是“git@github.com:schacon/hw.git”。 97 | 要把它添加到我们的项目以便我们推送以及获取更新,我们可以这样: 98 |

99 | 100 |
101 | $ git remote
102 | $ git remote add github git@github.com:schacon/hw.git
103 | $ git remote -v
104 | github	git@github.com:schacon/hw.git (fetch)
105 | github	git@github.com:schacon/hw.git (push)
106 | 
107 | 108 |

109 | 像分支的命名一样,远端仓库的别名是强制的 —— 就像“master”,没有特别意义,但它广为使用, 110 | 因为 git init 默认用它;“origin”经常被用作远端仓库别名,就因为 git clone 111 | 默认用它作为克隆自的链接的别名。此例中,我决定给我的远端仓库取名“github”,但我叫它随便什么都可以。 112 |

113 | 114 |

115 | git remote rm 116 | 删除现存的某个别名 117 |

118 | 119 |

120 | Git addeth and Git taketh away. 如果你需要删除一个远端 —— 不再需要它了、项目已经没了,等等 —— 你可以使用 git remote rm [alias] 把它删掉。 121 |

122 | 123 |
124 | $ git remote -v
125 | github	git@github.com:schacon/hw.git (fetch)
126 | github	git@github.com:schacon/hw.git (push)
127 | $ git remote add origin git://github.com/pjhyett/hw.git
128 | $ git remote -v
129 | github	git@github.com:schacon/hw.git (fetch)
130 | github	git@github.com:schacon/hw.git (push)
131 | origin	git://github.com/pjhyett/hw.git (fetch)
132 | origin	git://github.com/pjhyett/hw.git (push)
133 | $ git remote rm origin
134 | $ git remote -v
135 | github	git@github.com:schacon/hw.git (fetch)
136 | github	git@github.com:schacon/hw.git (push)
137 | 
138 | 139 |

140 | 简而言之 你可以用 git remote 列出你的远端仓库和那些仓库的链接。 141 | 你可以使用 git remote add 添加新的远端仓库,用 git remote rm 删掉已存在的那些。 142 |

143 | 144 |
145 |
146 | 147 |
148 |

149 | 150 | 文档   151 | 152 | 153 | git fetch 154 | 从远端仓库下载新分支与数据 155 |

156 | 157 |
158 | 159 |

160 | 161 | 文档   162 | 163 | 164 | git pull 165 | 从远端仓库提取数据并尝试合并到当前分支 166 |

167 | 168 |
169 | 170 |

171 | Git 有两个命令用来从某一远端仓库更新。 172 | git fetch 会使你与另一仓库同步,提取你本地所没有的数据,为你在同步时的该远端的每一分支提供书签。 173 | 这些分支被叫做“远端分支”,除了 Git 不允许你检出(切换到该分支)之外,跟本地分支没区别 —— 174 | 你可以将它们合并到当前分支,与其他分支作比较差异,查看那些分支的历史日志,等等。同步之后你就可以在本地操作这些。 175 |

176 | 177 |

178 | 第二个会从远端服务器提取新数据的命令是 git pull。 179 | 基本上,该命令就是在 git fetch 之后紧接着 git merge 远端分支到你所在的任意分支。 180 | 我个人不太喜欢这命令 —— 我更喜欢 fetchmerge 分开来做。少点魔法,少点问题。 181 | 不过,如果你喜欢这主意,你可以看一下 git pull 的 182 | 官方文档。 183 |

184 | 185 |

186 | 假设你配置好了一个远端,并且你想要提取更新,你可以首先执行 git fetch [alias] 187 | 告诉 Git 去获取它有你没有的数据,然后你可以执行 git merge [alias]/[branch] 188 | 以将服务器上的任何更新(假设有人这时候推送到服务器了)合并到你的当前分支。 189 | 那么,如果我是与两三个其他人合作 Hello World 项目,并且想要将我最近连接之后的所有改动拿过来,我可以这么做: 190 |

191 | 192 |
193 | $ git fetch github
194 | remote: Counting objects: 4006, done.
195 | remote: Compressing objects: 100% (1322/1322), done.
196 | remote: Total 2783 (delta 1526), reused 2587 (delta 1387)
197 | Receiving objects: 100% (2783/2783), 1.23 MiB | 10 KiB/s, done.
198 | Resolving deltas: 100% (1526/1526), completed with 387 local objects.
199 | From github.com:schacon/hw
200 |    8e29b09..c7c5a10  master     -> github/master
201 |    0709fdc..d4ccf73  c-langs    -> github/c-langs
202 |    6684f82..ae06d2b  java       -> github/java
203 |  * [new branch]      ada        -> github/ada
204 |  * [new branch]      lisp       -> github/lisp
205 | 
206 | 207 |

208 | 可以看到自从上一次与远端仓库同步以后,又新赠或更新了五个分支。 209 | “ada”与“lisp”分支是新的,而“master”、“clang”与“java”分支则被更新了。 210 | 在此例中,我的团队在合并入主分支之前,将提议的更新推送到远端分支以审核。 211 |

212 | 213 |

214 | 你可以看到 Git 做的映射。远端仓库的主分支成为了本地的一个叫做“github/master”的分支。 215 | 这样我就可以执行 git merge github/master 将远端的主分支和并入我的本地主分支。 216 | 或者,我可以 git log github/master ^master 看看该分支上的新提交。 217 | 如果你的远端仓库叫做“origin”,那远端主分支就会叫做 origin/master。几乎所有能在本地分支上执行的命令都可以在远端分支上用。 218 |

219 | 220 |

221 | 如果你有多个远端仓库,你可以执行 git fetch [alias] 提取特定的远端仓库, 222 | 或者执行 git fetch --all 告诉 Git 同步所有的远端仓库。 223 |

224 | 225 |

226 | 简而言之 执行 git fetch [alias] 来将你的仓库与远端仓库同步,提取所有它独有的数据到本地分支以合并或者怎样。 227 |

228 | 229 |
230 | 231 |
232 | 233 |
234 |

235 | 236 | 文档   237 | 238 | 239 | git push 240 | 推送你的新分支与数据到某个远端仓库 241 |

242 | 243 |
244 |

245 | 想要与他人分享你牛鼻的提交,你需要将改动推送到远端仓库。 246 | 执行 git push [alias] [branch],就会将你的 [branch] 分支推送成为 [alias] 远端上的 [branch] 分支。 247 | 让我们试试推送我们的主分支到先前添加的“github”远端仓库上去。 248 |

249 | 250 |
251 | $ git push github master
252 | Counting objects: 25, done.
253 | Delta compression using up to 2 threads.
254 | Compressing objects: 100% (25/25), done.
255 | Writing objects: 100% (25/25), 2.43 KiB, done.
256 | Total 25 (delta 4), reused 0 (delta 0)
257 | To git@github.com:schacon/hw.git
258 |  * [new branch]      master -> master
259 | 
260 | 261 |

262 | 挺简单。现在如果有人从该仓库克隆,他会得到我提交的完完全全的一份历史记录了。 263 |

264 | 265 |

266 | 如果有个像之前创建的“erlang”分支那样的主题分支,想只分享这个,该怎么办呢?你可以相应的只推送该分支。 267 |

268 | 269 |
270 | $ git push github erlang
271 | Counting objects: 7, done.
272 | Delta compression using up to 2 threads.
273 | Compressing objects: 100% (6/6), done.
274 | Writing objects: 100% (6/6), 652 bytes, done.
275 | Total 6 (delta 1), reused 0 (delta 0)
276 | To git@github.com:schacon/hw.git
277 |  * [new branch]      erlang -> erlang
278 | 
279 | 280 |

281 | 现在当人们从该仓库克隆时,他们就会得到一个“erlang”分支以查阅、合并。 282 | 用这种方式,你可以推送任何分支到任何你有写权限的仓库。 283 | 如果你的分支已经在该仓库中了,它会试着去更新,如果它不再,Git 会把它加上。 284 |

285 | 286 |

287 | 最后一个当你推送到远端分支时会碰到的主要问题是,其他人在此期间也推送了的情况。 288 | 如果你和另一个开发者同时克隆了,又都有提交,那么当她推送后你也想推送时,默认情况下 Git 不会让你覆盖她的改动。 289 | 相反的,它会在你试图推送的分支上执行 git log,确定它能够在你的推送分支的历史记录中看到服务器分支的当前进度。 290 | 如果它在在你的历史记录中看不到,它就会下结论说你过时了,并打回你的推送。 291 | 你需要正式提取、合并,然后再次推送 —— 以确定你把她的改动也考虑在内了。 292 |

293 | 294 |

295 | 当你试图推送到某个以被更新的远端分支时,会出现下面这种情况: 296 |

297 | 298 |
299 | $ git push github master
300 | To git@github.com:schacon/hw.git
301 |  ! [rejected]        master -> master (non-fast-forward)
302 | error: failed to push some refs to 'git@github.com:schacon/hw.git'
303 | To prevent you from losing history, non-fast-forward updates were rejected
304 | Merge the remote changes before pushing again.  See the 'Note about
305 | fast-forwards' section of 'git push --help' for details.
306 | 
307 | 308 |

309 | 你可以修正这个问题。执行 git fetch github; git merge github/master,然后再推送 310 |

311 | 312 |

313 | 简而言之 执行 git push [alias] [branch] 将你的本地改动推送到远端仓库。 314 | 如果可以的话,它会依据你的 [branch] 的样子,推送到远端的 [branch] 去。 315 | 如果在你上次提取、合并之后,另有人推送了,Git 服务器会拒绝你的推送,知道你是最新的为止。 316 |

317 | 318 |
319 |
320 | 321 |

到 检查与比较»

322 | --------------------------------------------------------------------------------