Changes between Version 6 and Version 7 of GitCrashCourse
- Timestamp:
- 05/10/11 11:18:44 (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GitCrashCourse
v6 v7 1 == Cloning a git repository == 1 [[TOC(inline, depth=1)]] 2 3 = Cloning a git repository = 2 4 3 5 What 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. … … 9 11 The {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. 10 12 11 == Introducing yourself ==13 = Introducing yourself = 12 14 13 15 Git 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: … … 27 29 Some might only need to do the latter one, but some might want to use different e-mail addresses for their commits for different projects. 28 30 29 == Other neat features to enable ==30 31 === Making git colourful ===31 = Other neat features to enable = 32 33 == Making git colourful == 32 34 33 35 This is highly recommended, as it is easier to read commit logs and patches via the git commands this way. … … 48 50 }}} 49 51 50 === Preparing for sending patches via mail ===52 == Preparing for sending patches via mail == 51 53 52 54 If 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. … … 68 70 You can also set your password in the config, by setting sendemail.smtppass - '''but the password will be saved in clear text!''' 69 71 70 === Configuration files ===72 == Configuration files == 71 73 72 74 Now do this: … … 79 81 As you can see, the configuration files are not that hard to read. These files may be edited manually if you want to as well. 80 82 81 == Checking the status of the project == 83 = Concepts = 84 85 == Tags == 86 87 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: 88 89 {{{ 90 git tag -l 91 }}} 92 93 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. 94 95 == Branches == 96 97 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. 98 99 First, let's look at some branches: 100 101 {{{ 102 git branch 103 }}} 104 105 This will list all your local branches. But we also have some remote branches. 106 107 {{{ 108 git branch -r 109 }}} 110 111 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. 112 113 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. 114 115 = Common tasks = 116 117 == Checking the status of the project == 82 118 83 119 {{{ … … 87 123 This 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. 88 124 89 125 == Checking your changes == 90 126 91 127 {{{ … … 95 131 This will list all local changes which has not been committed. 96 132 97 133 == Saving changes == 98 134 99 135 All 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: … … 139 175 This 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. 140 176 141 177 == Look at the commit log == 142 178 143 179 {{{ … … 167 203 }}} 168 204 169 205 == Creating patch files == 170 206 171 207 When you have done some commits, you probably want to share them. Say you want to pick out the last commit. … … 193 229 You can also do this with ''git log'' to see which patche files ''git format-patch'' will generate. 194 230 195 == Sending patches to the OpenVPN devel-mailing list ==231 == Sending patches to the openvpn-devel mailing list == 196 232 197 233 If 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: … … 203 239 and follow the instructions you're given. That's all. 204 240 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 == 236 242 237 243 In OpenVPN, there's a branch called ''allmerged''. So to checkout that branch locally, we do: … … 251 257 And it will create a new branch, enter it, from the latest commit where you where. You can now even commit into this branch. 252 258 253 === Merge branches === 259 == Merge branches == 254 260 255 261 If 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.