Changes between Version 6 and Version 7 of GitCrashCourse


Ignore:
Timestamp:
05/10/11 11:18:44 (13 years ago)
Author:
Samuli Seppänen
Comment:

Reorganized GitCrashCourse and added a table of contents

Legend:

Unmodified
Added
Removed
Modified
  • GitCrashCourse

    v6 v7  
    1  == Cloning a git repository ==
     1[[TOC(inline, depth=1)]]
     2
     3= Cloning a git repository =
    24
    35What this means is that you actually download the complete code repository to your own hard drive.  This is different from centralised VCS/SCMs, which only have a copy of the files you checked out.  With git you get a complete copy of the complete history, locally.  This is one of the reasons why git can be very quick.
     
    911The {repository} string can point at a git://, ssh://, http[s]:// URL or a file path to a local directory.  When the cloning is completed, you will automatically have checked out the 'master' branch.
    1012
    11  == Introducing yourself ==
     13= Introducing yourself =
    1214
    1315Git should know who you are, as that will be important for the git commit logs.  So please enter a directory created by ''git clone'' and do:
     
    2729Some might only need to do the latter one, but some might want to use different e-mail addresses for their commits for different projects.
    2830
    29  == Other neat features to enable ==
    30 
    31  === Making git colourful ===
     31= Other neat features to enable =
     32
     33== Making git colourful ==
    3234
    3335This is highly recommended, as it is easier to read commit logs and patches via the git commands this way.
     
    4850 }}}
    4951
    50  === Preparing for sending patches via mail ===
     52== Preparing for sending patches via mail ==
    5153
    5254If you choose to install the git-send-email package, you can very easily submit patches via e-mail.  We will go into these details later on, but some configuration should be done.
     
    6870You can also set your password in the config, by setting sendemail.smtppass - '''but the password will be saved in clear text!'''
    6971
    70  === Configuration files ===
     72== Configuration files ==
    7173
    7274Now do this:
     
    7981As you can see, the configuration files are not that hard to read.  These files may be edited manually if you want to as well.
    8082
    81  == Checking the status of the project ==
     83= Concepts =
     84
     85== Tags ==
     86
     87If you wonder where 'v2.1_rc15' came from in the example above, that's a tag name.  And tags can be found by doing:
     88
     89 {{{
     90 git tag -l
     91 }}}
     92
     93A tag is just a name of a particular commit ID.  Commit ID's can be tricky to remember, and then you can insert tag names which are a bit more descriptive.
     94
     95== Branches ==
     96
     97Branches are almost the same as tags, but with one difference - you can commit to them.  You can also quickly create your own branch to test out things, without being worried about your former commits.
     98
     99First, let's look at some branches:
     100
     101{{{
     102git branch
     103}}}
     104
     105This will list all your local branches.  But we also have some remote branches.
     106
     107{{{
     108git branch -r
     109}}}
     110
     111Notice the difference between them, where remote branches are prefixed with ''origin/''.  This is because git tracks remote branches separately from your local branches.  So you can have a master branch which is different from origin/master.  Another thing, to be able to do commits on remote branches, you must check them out as a local branch before you can do commit.
     112
     113You can also add more remote repositories, and will then have different remote names.  ''origin'' is just a remote name, which is the default name for the remote where you did your initial clone.  We will not dig into this here.
     114
     115= Common tasks =
     116
     117== Checking the status of the project ==
    82118
    83119 {{{
     
    87123This command gives you an overview over all files which have been modified and all new and unregistered files.  The output of ''git status'' should be pretty obvious.
    88124
    89  == Checking your changes ==
     125== Checking your changes ==
    90126
    91127 {{{
     
    95131This will list all local changes which has not been committed.
    96132
    97  == Saving changes ==
     133== Saving changes ==
    98134
    99135All files new files will need to be added to an ''index'' to be prepared for a commit.  Consider this as a "pre stage" which needs to be done.  This is also different from other VCS/SCMs.  But it has it's advantages as well.  So if you add or modifies files, you need to do this to add files to the index when you want to commit your changes:
     
    139175This is important to remember if you apply patches from others.  This way it is possible to track from whom the different code parts came from.
    140176
    141  == Look at the commit log ==
     177== Look at the commit log ==
    142178
    143179 {{{
     
    167203 }}}
    168204
    169  == Creating patch files ==
     205== Creating patch files ==
    170206
    171207When you have done some commits, you probably want to share them.  Say you want to pick out the last commit.
     
    193229You can also do this with ''git log'' to see which patche files ''git format-patch'' will generate.
    194230
    195  == Sending patches to the OpenVPN devel-mailing list ==
     231== Sending patches to the openvpn-devel mailing list ==
    196232
    197233If you have installed the git-send-email package and done the configuration steps mentioned above, sending patches to the mailing list is just as easy as creating the patch files.  Please note that the ''git send-email'' command expects to get patch file(s).  Just do:
     
    203239and follow the instructions you're given.  That's all.
    204240
    205  == Tags ==
    206 
    207 If you wonder where 'v2.1_rc15' came from in the example above, that's a tag name.  And tags can be found by doing:
    208 
    209  {{{
    210  git tag -l
    211  }}}
    212 
    213 A tag is just a name of a particular commit ID.  Commit ID's can be tricky to remember, and then you can insert tag names which are a bit more descriptive.
    214 
    215  == Branches ==
    216 
    217 Branches are almost the same as tags, but with one difference - you can commit to them.  You can also quickly create your own branch to test out things, without being worried about your former commits.
    218 
    219 First, let's look at some branches:
    220 
    221 {{{
    222 git branch
    223 }}}
    224 
    225 This will list all your local branches.  But we also have some remote branches.
    226 
    227 {{{
    228 git branch -r
    229 }}}
    230 
    231 Notice the difference between them, where remote branches are prefixed with ''origin/''.  This is because git tracks remote branches separately from your local branches.  So you can have a master branch which is different from origin/master.  Another thing, to be able to do commits on remote branches, you must check them out as a local branch before you can do commit.
    232 
    233 You can also add more remote repositories, and will then have different remote names.  ''origin'' is just a remote name, which is the default name for the remote where you did your initial clone.  We will not dig into this here.
    234 
    235  === Checkout a branch ===
     241== Checkout a branch ==
    236242
    237243In OpenVPN, there's a branch called ''allmerged''.  So to checkout that branch locally, we do:
     
    251257And it will create a new branch, enter it, from the latest commit where you where.  You can now even commit into this branch.
    252258
    253  === Merge branches ===
     259== Merge branches ==
    254260
    255261If you find out that one branch has some stuff you want to test out with your own stuff in your own branch, it's quite easy.