# snaewe/gitt forked from cbx33/gitt

 25939bb Added skeleton for chap5 and chap6 cbx33 authored Mar 28, 2011 1 % afterhours5.tex - Afer Hours Week 5 2 \chapter{After Hours Week 5} 2028f28 Finished Day 1 of chap5 cbx33 authored Mar 29, 2011 3 \section{Splitting up commits the easy way''} 03b5567 Started AF5 cbx33 authored Apr 13, 2011 4 \subsection{Taking commits that little bit further} ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 5 Sometimes, putting everything in a single commit just is not a good idea. 6 Imagine you have pulled in number of updates to your working directory. 7 You may want to split these up. 8 It is true that you could simply \texttt{git add} only the files you want to include in the commit. 9 However, what happens when you have change four or five different things in the same file, and you want to split that commit up into five different commits. 03b5567 Started AF5 cbx33 authored Apr 13, 2011 10 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 11 There are two ways you can approach this. 12 The first is to copy the file in question out of the working directory, reset the working copy back to the last committed and copy your changes in line by line. a77cdf2 Fix speling Johan Sageryd authored Jul 12, 2011 13 This can be time consuming and frustrating and when you are working on many files, it can be totally impractical. ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 14 What we need is a way to include or exclude certain lines of a file. 03b5567 Started AF5 cbx33 authored Apr 13, 2011 15 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 16 To demonstrate this we are going to create a new branch called \textbf{fantasy} and we are going to make several changes to a few files. 17 We are then going to show how the same process can be achieved by using both the GUI and the command line. 03b5567 Started AF5 cbx33 authored Apr 13, 2011 18 19 So let us start by creating our branch and making some changes as shown below. 20 ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 21 \begin{code} 03b5567 Started AF5 cbx33 authored Apr 13, 2011 22 john@satsuki:~/coderepo$git checkout -b fantasy 23 Switched to a new branch 'fantasy' ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 24 john@satsuki:~/coderepo$ echo "This is line 1" > newfile1 03b5567 Started AF5 cbx33 authored Apr 13, 2011 25 john@satsuki:~/coderepo$echo "This is line 2" >> newfile1 26 john@satsuki:~/coderepo$ echo "This is line 3" >> newfile1 27 john@satsuki:~/coderepo$echo "This is line 4" >> newfile1 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 28 john@satsuki:~/coderepo$ echo "This is a new line" >> newfile2 29 john@satsuki:~/coderepo$echo "This is another new line" >> newfile2 ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 30 \end{code} 03b5567 Started AF5 cbx33 authored Apr 13, 2011 31 32 Let us now just run a \texttt{git diff} to see exactly what the changes are. 33 ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 34 \begin{code} 03b5567 Started AF5 cbx33 authored Apr 13, 2011 35 john@satsuki:~/coderepo$ git diff 36 diff --git a/newfile1 b/newfile1 37 index 44640b2..0eccf1a 100644 38 --- a/newfile1 39 +++ b/newfile1 40 @@ -1,2 +1,4 @@ 41 -A new file 42 -and some more awesome changes 43 +This is line 1 44 +This is line 2 45 +This is line 3 46 +This is line 4 47 diff --git a/newfile2 b/newfile2 48 index 3545c1d..40efcce 100644 49 --- a/newfile2 50 +++ b/newfile2 51 @@ -1,2 +1,4 @@ 52 Another new file 53 and a new awesome feature 54 +This is a new line 55 +This is another new line ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 56 john@satsuki:~/coderepo$ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 57 \end{code} 03b5567 Started AF5 cbx33 authored Apr 13, 2011 58 62c1481 Squash double-space Johan Sageryd authored Jul 12, 2011 59 \index{hunk editing (cli)}Now, we could just do \texttt{git commit -a} and be done with it, but what if we really wanted to split this information up into four commits? We will introduce a new parameter to our \texttt{git add} tool from before. ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 60 We are going to use the \texttt{git add -p} or \texttt{git add --patch}. 61 This will allow us to interactively edit the hunks before they are committed. 62 To begin with, let us run \texttt{git add -p} and see what it is we need to do. f67ec36 Finished text based single line commits cbx33 authored Apr 14, 2011 63 ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 64 \begin{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 65 john@satsuki:~/coderepo$ git add -p 66 diff --git a/newfile1 b/newfile1 67 index 44640b2..0eccf1a 100644 68 --- a/newfile1 69 +++ b/newfile1 70 @@ -1,2 +1,4 @@ 71 -A new file 72 -and some more awesome changes 73 +This is line 1 74 +This is line 2 75 +This is line 3 76 +This is line 4 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 77 Stage this hunk [y,n,q,a,d,/,e,?]? ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 78 \end{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 79 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 80 We are given the options of \texttt{y,n,q,a,d,/,e,?}. 81 At first glance, this may seem rather daunting. 82 Let us choose the \texttt{?} and see what help is presented to us. f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 83 ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 84 \begin{code} ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 85 Stage this hunk [y,n,q,a,d,/,e,?]? ? f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 86 y - stage this hunk 87 n - do not stage this hunk 88 q - quit, do not stage this hunk nor any of the remaining ones 89 a - stage this and all the remaining hunks in the file 90 d - do not stage this hunk nor any of the remaining hunks in the file 91 g - select a hunk to go to 92 / - search for a hunk matching the given regex 93 j - leave this hunk undecided, see next undecided hunk 94 J - leave this hunk undecided, see next hunk 95 k - leave this hunk undecided, see previous undecided hunk 96 K - leave this hunk undecided, see previous hunk 97 s - split the current hunk into smaller hunks 98 e - manually edit the current hunk 99 ? - print help 100 @@ -1,2 +1,4 @@ 101 -A new file 102 -and some more awesome changes 103 +This is line 1 104 +This is line 2 105 +This is line 3 106 +This is line 4 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 107 Stage this hunk [y,n,q,a,d,/,e,?]? ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 108 \end{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 109 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 110 So it appears that Git is offering us the opportunity to either f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 111 \begin{itemize} 112 \item Stage it 113 \item Do not stage it ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 114 \item Quit, f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 115 \item Stage it and all remaining hunks 116 \item Do not stage it or any of the remaining ones 117 \item Search for a regex 118 \item Edit the hunk 119 \end{itemize} 120 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 121 In fact, though the help mentioned a \textbf{split} command, we do not have this option available to us, due to the nature of our hunk. 122 Instead, if we wish to split this hunk, we are going to have to edit it manually. 123 To do this we will choose the \texttt{e} option. f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 124 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 125 Here we are left in our chosen text editor, to either add, modify or remove lines from the hunk. 126 In our case, we are going to delete a few lines. 127 We only want to leave the first line of additions. 128 Just because we delete the others does not mean they are deleted from the working copy. 129 Remember, we are not editing the actual files here. 130 Just the hunks that are going to be staged. f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 131 ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 132 \begin{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 133 # Manual hunk edit mode -- see bottom for a quick guide 134 @@ -1,2 +1,4 @@ 135 -A new file 136 -and some more awesome changes 137 +This is line 1 138 +This is line 2 139 +This is line 3 140 +This is line 4 141 # --- 142 # To remove '-' lines, make them ' ' lines (context). 143 # To remove '+' lines, delete them. 144 # Lines starting with # will be removed. 145 # 146 # If the patch applies cleanly, the edited hunk will immediately be 147 # marked for staging. If it does not apply cleanly, you will be given 148 # an opportunity to edit again. If all lines of the hunk are removed, 149 # then the edit is aborted and the hunk is left unchanged. ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 150 \end{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 151 152 After the deletes, the editors file should look like this. 153 ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 154 \begin{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 155 # Manual hunk edit mode -- see bottom for a quick guide 156 @@ -1,2 +1,4 @@ 157 -A new file 158 -and some more awesome changes 159 +This is line 1 160 # --- 161 # To remove '-' lines, make them ' ' lines (context). 162 # To remove '+' lines, delete them. 163 # Lines starting with # will be removed. 164 # 165 # If the patch applies cleanly, the edited hunk will immediately be 166 # marked for staging. If it does not apply cleanly, you will be given 167 # an opportunity to edit again. If all lines of the hunk are removed, 168 # then the edit is aborted and the hunk is left unchanged. ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 169 \end{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 170 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 171 Once we quit our editor, we are then asked about the next hunk. 172 In our case, we are going to apply all of the changes to our second file during this commit. 173 To do this we are going to use the \texttt{a} option. f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 174 ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 175 \begin{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 176 diff --git a/newfile2 b/newfile2 177 index 3545c1d..40efcce 100644 178 --- a/newfile2 179 +++ b/newfile2 180 @@ -1,2 +1,4 @@ 181 Another new file 182 and a new awesome feature 183 +This is a new line 184 +This is another new line 185 Stage this hunk [y,n,q,a,d,/,e,?]? a 186 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 187 john@satsuki:~/coderepo$ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 188 \end{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 189 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 190 At first glance, we do not appear to have been left with any indication that anything has taken place. f6bdcb5 some minor typo fixes snaewe authored Aug 25, 2011 191 In order to perform a check we shall run our obligatory \texttt{git diff}, both between the working copy and the index, and between the index and the last commit. f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 192 ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 193 \begin{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 194 john@satsuki:~/coderepo$ git diff 195 diff --git a/newfile1 b/newfile1 196 index f702b65..0eccf1a 100644 197 --- a/newfile1 198 +++ b/newfile1 199 @@ -1 +1,4 @@ 200 This is line 1 201 +This is line 2 202 +This is line 3 203 +This is line 4 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 204 john@satsuki:~/coderepo$ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 205 \end{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 206 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 207 So above, we can see that the difference between the working copy and the index, or staging area, is the last three lines that we are not ready to commit yet. 208 Below we can see the difference between the staging area and the last commit to the repository. 209 This includes the three lines that we included during our interactive commit preparation. f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 210 ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 211 \begin{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 212 john@satsuki:~/coderepo$ git diff --cached 213 diff --git a/newfile1 b/newfile1 214 index 44640b2..f702b65 100644 215 --- a/newfile1 216 +++ b/newfile1 217 @@ -1,2 +1 @@ 218 -A new file 219 -and some more awesome changes 220 +This is line 1 221 diff --git a/newfile2 b/newfile2 222 index 3545c1d..40efcce 100644 223 --- a/newfile2 224 +++ b/newfile2 225 @@ -1,2 +1,4 @@ 226 Another new file 227 and a new awesome feature 228 +This is a new line 229 +This is another new line ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 230 john@satsuki:~/coderepo$ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 231 \end{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 232 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 233 We can now commit in the normal way, and continue to edit the working copy to stage the sections we require. 234 The following output is shortened for brevity. f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 235 ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 236 \begin{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 237 john@satsuki:~/coderepo$ git commit -m 'Added first line' 238 [fantasy 03bd20c] Added first line 239 2 files changed, 3 insertions(+), 2 deletions(-) 240 john@satsuki:~/coderepo$git add -p 241 diff --git a/newfile1 b/newfile1 242 index f702b65..0eccf1a 100644 243 --- a/newfile1 244 +++ b/newfile1 245 @@ -1 +1,4 @@ 246 This is line 1 247 +This is line 2 248 +This is line 3 249 +This is line 4 250 Stage this hunk [y,n,q,a,d,/,e,?]? e 251 252 john@satsuki:~/coderepo$ git commit -m 'Added second line' 253 [fantasy 302e3fa] Added second line 254 1 files changed, 1 insertions(+), 0 deletions(-) 255 john@satsuki:~/coderepo$git add -p 256 ... 257 ... ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 258 \end{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 259 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 260 We have gone through the process of editing each hunk for each commit and have performed the commits. f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 261 ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 262 \begin{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 263 john@satsuki:~/coderepo$ git log 264 commit a59e73b1dc571318a1154aa4c2fc591ab6f1f395 265 Author: John Haskins 266 Date: Wed Apr 13 23:56:39 2011 +0100 267 268 Added fourth line 269 270 commit 3ca3d627a54418be4c2e9d9196db6ce62e2b93ff 271 Author: John Haskins 272 Date: Wed Apr 13 23:56:13 2011 +0100 273 274 Added third line 275 276 commit 302e3fa5f880a2a503235667b4c96d4dcdaa11be 277 Author: John Haskins 278 Date: Wed Apr 13 23:55:57 2011 +0100 279 280 Added second line 281 282 commit 03bd20cb8a78a28f003ab402492cf7055f21bb2e 283 Author: John Haskins 284 Date: Wed Apr 13 23:55:32 2011 +0100 285 286 Added first line c0faf01 More changes from the book proof (physical) cbx33 authored Sep 16, 2011 287 ... 288 ... ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 289 \end{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 290 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 291 \index{hunk editing(gui)}Next we are going to see how to perform exactly the same procedure using \texttt{git gui}. 292 For a start, we are going to reset our branch HEAD and our index back to their state before we made the last four commits, however we are going to leave the working copy files in the state they were after these last four commits. 293 This is called a \textbf{mixed} reset, as it modifies the staging area and the HEAD, but does not touch the working files. f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 294 ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 295 \begin{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 296 john@satsuki:~/coderepo$git log --oneline 297 a59e73b Added fourth line 298 3ca3d62 Added third line 299 302e3fa Added second line 300 03bd20c Added first line 301 d50ffb2 Merged in zaney 302 ed2301b Removed third file 303 ... 304 ... 305 john@satsuki:~/coderepo$ git reset --mixed d50ffb2 306 Unstaged changes after reset: 307 M newfile1 308 M newfile2 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 309 john@satsuki:~/coderepo$ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 310 \end{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 311 312 Now we will run a diff, just to be sure. 313 ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 314 \begin{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 315 john@satsuki:~/coderepo$ git diff 316 diff --git a/newfile1 b/newfile1 317 index 44640b2..0eccf1a 100644 318 --- a/newfile1 319 +++ b/newfile1 320 @@ -1,2 +1,4 @@ 321 -A new file 322 -and some more awesome changes 323 +This is line 1 324 +This is line 2 325 +This is line 3 326 +This is line 4 327 diff --git a/newfile2 b/newfile2 328 index 3545c1d..40efcce 100644 329 --- a/newfile2 330 +++ b/newfile2 331 @@ -1,2 +1,4 @@ 332 Another new file 333 and a new awesome feature 334 +This is a new line 335 +This is another new line ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 336 john@satsuki:~/coderepo$ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 337 \end{code} f67ec36 Finished text based single line commits cbx33 authored Apr 13, 2011 338 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 339 If we now run our \texttt{git gui} command, we will see the changes that are present, once we click on one of the files in the left hand portion of the screen. 340 Let us start with \texttt{newfile2} as we want every change from that file present in this commit. 341 Figure 1 shows what \texttt{git gui} looks like at this stage. b9ac502 Added new images for AF5 cbx33 authored Apr 14, 2011 342 56ba1d7 Fixed images in AF2,5,7 cbx33 authored Aug 14, 2011 343 \figuregith{10cm}{images/f-af5-d1.png}{Changes to \texttt{newfile2}} b9ac502 Added new images for AF5 cbx33 authored Apr 14, 2011 344 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 345 If we right click on one of the green lines, remembering that green is short for an \textbf{addition}, we get a menu which we have not seen before. 346 Among other things, this menu has the ability to stage a specific line or hunk for commit. 347 In our case we are going to hit the \textbf{Stage Hunk For Commit} and then move on to the next file, \texttt{newfile1}. f10fb8d Finished off AF5 cbx33 authored Apr 14, 2011 348 56ba1d7 Fixed images in AF2,5,7 cbx33 authored Aug 14, 2011 349 \figuregith{10cm}{images/f-af5-d2.png}{Changes to \texttt{newfile1}} 4f3ba64 Added links for new images cbx33 authored Apr 14, 2011 350 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 351 Now we are looking at \texttt{newfile1}, we can use the \textbf{Stage Line For Commit} to add specific lines into the staging area. 352 The file is shown in Figure 2. 353 As our file is so small, we can run into problems if we just choose lines at random and stage them. 354 This is because it is hard for Git to find context around which to associate the change. 355 The context is the area immediately surrounding the change we are making. 356 In order to reduce the risk of the error occurring, we are simply going to start at the top, and select the first three lines for committing, by right clicking on each on in turn and choosing the \textbf{Stage Line For Commit} option from the menu. f10fb8d Finished off AF5 cbx33 authored Apr 14, 2011 357 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 358 We have the changes that we expect ready to be committed. 359 If we want to check one last time that they are right, we can use the \textbf{Staged Changes} pane on the left to choose the file and inspect the diff. 360 Once we are happy we can use the \textbf{Commit} area of the window to type our commit message and emblazon our changes forever. f10fb8d Finished off AF5 cbx33 authored Apr 14, 2011 361 56ba1d7 Fixed images in AF2,5,7 cbx33 authored Aug 14, 2011 362 \figuregith{10cm}{images/f-af5-d3.png}{Changes to \texttt{newfile1} after staging} f10fb8d Finished off AF5 cbx33 authored Apr 14, 2011 363 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 364 Figure 3, shows what our file looks like after the first commit. 365 Interestingly, as our file is so small, you will probably find that \texttt{git gui} throws a corrupt patch error if you try to just commit the next line. 366 As we mentioned earlier, it is always a good idea to know how to use the command line tools for precisely this reason. 367 Often you are dealing with special cases, that the GUI just can not handle. 368 In these cases, you may find you need to switch to the command line interface, to get the job done. f10fb8d Finished off AF5 cbx33 authored Apr 14, 2011 369 951945d Added deletion of fantasy branch to end of Week 5 to bring repo in line cbx33 authored Apr 19, 2011 370 Let us now move back to our \textbf{master} branch and remove the \textbf{fantasy} branch. 371 ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 372 \begin{code} 951945d Added deletion of fantasy branch to end of Week 5 to bring repo in line cbx33 authored Apr 19, 2011 373 john@satsuki:~/coderepo$ git checkout master 374 Switched to branch 'master' 375 john@satsuki:~/coderepo$git branch -D fantasy 376 Deleted branch fantasy (was 29ceede). ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 377 john@satsuki:~/coderepo$ ba9ffb2 Replace the Verbatim environment with custom listings environment Johan Sageryd authored Jul 12, 2011 378 \end{code} 951945d Added deletion of fantasy branch to end of Week 5 to bring repo in line cbx33 authored Apr 19, 2011 379 c51949c Use capital rather than capitol dsas authored Jan 7, 2012 380 Notice that because we used the capital \texttt{-D} parameter, we were not asked if we were sure we wanted to delete the \textbf{fantasy} branch. 951945d Added deletion of fantasy branch to end of Week 5 to bring repo in line cbx33 authored Apr 19, 2011 381 ee21326 Remove trailing whitespace and wrap lines Johan Sageryd authored Jul 12, 2011 382 So in the \emph{After Hours} section this week, we have found two ways to do the same complex task, one graphical and one command based. 383 Staging commits in this way may seem rather odd, but it will help you to keep your commits exceedingly exact. 384 Whilst this may not matter on a personal project, for Tamagoyaki Inc, grouping the right lines together in a commit will be an extremely useful process to have available.