Skip to content

Commit 5eefcf8

Browse files
committed
docs: Adds section on advanced git usage
Adds a section on rebasing, cherry-picking, stashing, and submodules. Closes #4
1 parent c163049 commit 5eefcf8

7 files changed

Lines changed: 69 additions & 39 deletions

File tree

Git Tutorial.aux

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,14 @@
6161
\@writefile{toc}{\contentsline {subsubsection}{\numberline {7.2.3}Relative Referencing from HEAD}{17}{subsubsection.7.2.3}\protected@file@percent }
6262
\@writefile{toc}{\contentsline {subsection}{\numberline {7.3}Combining Commits}{18}{subsection.7.3}\protected@file@percent }
6363
\@writefile{toc}{\contentsline {subsection}{\numberline {7.4}Bisect}{19}{subsection.7.4}\protected@file@percent }
64-
\@writefile{toc}{\contentsline {section}{\numberline {8}Using GitHub}{19}{section.8}\protected@file@percent }
65-
\@writefile{toc}{\contentsline {subsection}{\numberline {8.1}ReadMe}{19}{subsection.8.1}\protected@file@percent }
66-
\@writefile{toc}{\contentsline {subsection}{\numberline {8.2}Creating Releases}{20}{subsection.8.2}\protected@file@percent }
67-
\@writefile{toc}{\contentsline {subsection}{\numberline {8.3}Creating Issues}{20}{subsection.8.3}\protected@file@percent }
68-
\@writefile{toc}{\contentsline {section}{\numberline {9}Conclusion}{21}{section.9}\protected@file@percent }
69-
\gdef \@abspage@last{21}
64+
\@writefile{toc}{\contentsline {section}{\numberline {8}Advanced Usage of Git}{19}{section.8}\protected@file@percent }
65+
\@writefile{toc}{\contentsline {subsection}{\numberline {8.1}Rebasing}{19}{subsection.8.1}\protected@file@percent }
66+
\@writefile{toc}{\contentsline {subsection}{\numberline {8.2}Cherry-picking}{19}{subsection.8.2}\protected@file@percent }
67+
\@writefile{toc}{\contentsline {subsection}{\numberline {8.3}Stashing Incomplete Changes}{20}{subsection.8.3}\protected@file@percent }
68+
\@writefile{toc}{\contentsline {subsection}{\numberline {8.4}Submodules}{20}{subsection.8.4}\protected@file@percent }
69+
\@writefile{toc}{\contentsline {section}{\numberline {9}Using GitHub}{20}{section.9}\protected@file@percent }
70+
\@writefile{toc}{\contentsline {subsection}{\numberline {9.1}ReadMe}{20}{subsection.9.1}\protected@file@percent }
71+
\@writefile{toc}{\contentsline {subsection}{\numberline {9.2}Creating Releases}{21}{subsection.9.2}\protected@file@percent }
72+
\@writefile{toc}{\contentsline {subsection}{\numberline {9.3}Creating Issues}{22}{subsection.9.3}\protected@file@percent }
73+
\@writefile{toc}{\contentsline {section}{\numberline {10}Conclusion}{22}{section.10}\protected@file@percent }
74+
\gdef \@abspage@last{22}

Git Tutorial.log

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This is pdfTeX, Version 3.141592653-2.6-1.40.23 (MiKTeX 21.8) (preloaded format=pdflatex 2021.10.5) 26 OCT 2021 10:06
1+
This is pdfTeX, Version 3.141592653-2.6-1.40.23 (MiKTeX 21.8) (preloaded format=pdflatex 2021.10.5) 26 OCT 2021 10:42
22
entering extended mode
33
**"./Git Tutorial.tex"
44
(Git Tutorial.tex
@@ -422,7 +422,7 @@ LaTeX Font Info: External font `cmex10' loaded for size
422422

423423
[2]
424424
(Images/repositories.pdf_tex
425-
<Images//repositories.pdf, id=261, page=1, 673.41853pt x 670.94444pt>
425+
<Images//repositories.pdf, id=286, page=1, 673.41853pt x 670.94444pt>
426426
File: Images//repositories.pdf Graphic file (type pdf)
427427
<use Images//repositories.pdf, page 1>
428428
Package pdftex.def Info: Images//repositories.pdf , page1 used on input line 56
@@ -434,20 +434,20 @@ LaTeX Font Info: External font `cmex10' loaded for size
434434
(Font) <20.74> on input line 57.
435435
LaTeX Font Info: External font `cmex10' loaded for size
436436
(Font) <17.28> on input line 57.
437-
<Images//repositories.pdf, id=262, page=2, 673.41853pt x 670.94444pt>
437+
<Images//repositories.pdf, id=287, page=2, 673.41853pt x 670.94444pt>
438438
File: Images//repositories.pdf Graphic file (type pdf)
439439
<use Images//repositories.pdf, page 2>
440440
Package pdftex.def Info: Images//repositories.pdf , page2 used on input line 59
441441
.
442442
(pdftex.def) Requested size: 469.75499pt x 468.03009pt.
443443
) (Images/commit-history.pdf_tex
444-
<Images//commit-history.pdf, id=263, page=1, 887.13869pt x 304.73422pt>
444+
<Images//commit-history.pdf, id=288, page=1, 887.13869pt x 304.73422pt>
445445
File: Images//commit-history.pdf Graphic file (type pdf)
446446
<use Images//commit-history.pdf, page 1>
447447
Package pdftex.def Info: Images//commit-history.pdf , page1 used on input line
448448
56.
449449
(pdftex.def) Requested size: 469.75499pt x 161.35957pt.
450-
<Images//commit-history.pdf, id=264, page=2, 887.13869pt x 304.73422pt>
450+
<Images//commit-history.pdf, id=289, page=2, 887.13869pt x 304.73422pt>
451451
File: Images//commit-history.pdf Graphic file (type pdf)
452452
<use Images//commit-history.pdf, page 2>
453453
Package pdftex.def Info: Images//commit-history.pdf , page2 used on input line
@@ -458,7 +458,7 @@ Package pdftex.def Info: Images//commit-history.pdf , page2 used on input line
458458
pdfTeX warning: pdflatex (file ./Images//repositories.pdf): PDF inclusion: mult
459459
iple pdfs with page group included in a single page
460460
>] (Images/remote-repos.pdf_tex
461-
<Images//remote-repos.pdf, id=271, page=1, 649.18867pt x 894.94525pt>
461+
<Images//remote-repos.pdf, id=296, page=1, 649.18867pt x 894.94525pt>
462462
File: Images//remote-repos.pdf Graphic file (type pdf)
463463
<use Images//remote-repos.pdf, page 1>
464464
Package pdftex.def Info: Images//remote-repos.pdf , page1 used on input line 56
@@ -473,28 +473,28 @@ ltiple pdfs with page group included in a single page
473473
pdfTeX warning: pdflatex (file ./Images//remote-repos.pdf): PDF inclusion: mult
474474
iple pdfs with page group included in a single page
475475
>] [5] [6] [7] [8]
476-
<Images//GPG Key Listing.png, id=372, 507.0945pt x 151.16475pt>
476+
<Images//GPG Key Listing.png, id=397, 507.0945pt x 151.16475pt>
477477
File: Images//GPG Key Listing.png Graphic file (type png)
478478
<use Images//GPG Key Listing.png>
479479
Package pdftex.def Info: Images//GPG Key Listing.png used on input line 221.
480480
(pdftex.def) Requested size: 253.54662pt x 75.58218pt.
481481
[9] [10 <./Images//GPG Key Listing.png>] [11] [12] [13]
482482
[14] [15] [16] [17]
483-
<Images//Git Tree.png, id=457, 196.93575pt x 274.02374pt>
483+
<Images//Git Tree.png, id=482, 196.93575pt x 274.02374pt>
484484
File: Images//Git Tree.png Graphic file (type png)
485485
<use Images//Git Tree.png>
486486
Package pdftex.def Info: Images//Git Tree.png used on input line 405.
487487
(pdftex.def) Requested size: 177.24051pt x 246.61908pt.
488-
[18 <./Images//Git Tree.png>] [19] [20] [21]
488+
[18 <./Images//Git Tree.png>] [19] [20] [21] [22]
489489
(Git Tutorial.aux)
490490
Package rerunfilecheck Info: File `"Git Tutorial".out' has not changed.
491-
(rerunfilecheck) Checksum: 7ED86E1C8BCACB4540E0754A35B92C50;8393.
491+
(rerunfilecheck) Checksum: A32BCA3CF9E3D5652755E28C3EF5B071;9085.
492492
)
493493
Here is how much of TeX's memory you used:
494-
10357 strings out of 478868
495-
156891 string characters out of 2848809
496-
482997 words of memory out of 3000000
497-
27952 multiletter control sequences out of 15000+600000
494+
10368 strings out of 478868
495+
157040 string characters out of 2848809
496+
483002 words of memory out of 3000000
497+
27957 multiletter control sequences out of 15000+600000
498498
411779 words of font info for 54 fonts, out of 8000000 for 9000
499499
1141 hyphenation exceptions out of 8191
500500
62i,15n,75p,1859b,514s stack positions out of 5000i,500n,10000p,200000b,80000s
@@ -507,9 +507,9 @@ amsfonts/cm/cmbx12.pfb><C:/Users/nblch/AppData/Local/Programs/MiKTeX/fonts/type
507507
ms/MiKTeX/fonts/type1/public/amsfonts/cm/cmr12.pfb><C:/Users/nblch/AppData/Loca
508508
l/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmr17.pfb><C:/Users/nblch/AppD
509509
ata/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/cmsy10.pfb>
510-
Output written on "Git Tutorial.pdf" (21 pages, 285939 bytes).
510+
Output written on "Git Tutorial.pdf" (22 pages, 293584 bytes).
511511
PDF statistics:
512-
549 PDF objects out of 1000 (max. 8388607)
513-
158 named destinations out of 1000 (max. 500000)
514-
428 words of extra memory for PDF output out of 10000 (max. 10000000)
512+
580 PDF objects out of 1000 (max. 8388607)
513+
164 named destinations out of 1000 (max. 500000)
514+
468 words of extra memory for PDF output out of 10000 (max. 10000000)
515515

Git Tutorial.out

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,13 @@
4242
\BOOKMARK [3][-]{subsubsection.7.2.3}{\376\377\000R\000e\000l\000a\000t\000i\000v\000e\000\040\000R\000e\000f\000e\000r\000e\000n\000c\000i\000n\000g\000\040\000f\000r\000o\000m\000\040\000H\000E\000A\000D}{subsection.7.2}% 42
4343
\BOOKMARK [2][-]{subsection.7.3}{\376\377\000C\000o\000m\000b\000i\000n\000i\000n\000g\000\040\000C\000o\000m\000m\000i\000t\000s}{section.7}% 43
4444
\BOOKMARK [2][-]{subsection.7.4}{\376\377\000B\000i\000s\000e\000c\000t}{section.7}% 44
45-
\BOOKMARK [1][-]{section.8}{\376\377\000U\000s\000i\000n\000g\000\040\000G\000i\000t\000H\000u\000b}{}% 45
46-
\BOOKMARK [2][-]{subsection.8.1}{\376\377\000R\000e\000a\000d\000M\000e}{section.8}% 46
47-
\BOOKMARK [2][-]{subsection.8.2}{\376\377\000C\000r\000e\000a\000t\000i\000n\000g\000\040\000R\000e\000l\000e\000a\000s\000e\000s}{section.8}% 47
48-
\BOOKMARK [2][-]{subsection.8.3}{\376\377\000C\000r\000e\000a\000t\000i\000n\000g\000\040\000I\000s\000s\000u\000e\000s}{section.8}% 48
49-
\BOOKMARK [1][-]{section.9}{\376\377\000C\000o\000n\000c\000l\000u\000s\000i\000o\000n}{}% 49
45+
\BOOKMARK [1][-]{section.8}{\376\377\000A\000d\000v\000a\000n\000c\000e\000d\000\040\000U\000s\000a\000g\000e\000\040\000o\000f\000\040\000G\000i\000t}{}% 45
46+
\BOOKMARK [2][-]{subsection.8.1}{\376\377\000R\000e\000b\000a\000s\000i\000n\000g}{section.8}% 46
47+
\BOOKMARK [2][-]{subsection.8.2}{\376\377\000C\000h\000e\000r\000r\000y\000-\000p\000i\000c\000k\000i\000n\000g}{section.8}% 47
48+
\BOOKMARK [2][-]{subsection.8.3}{\376\377\000S\000t\000a\000s\000h\000i\000n\000g\000\040\000I\000n\000c\000o\000m\000p\000l\000e\000t\000e\000\040\000C\000h\000a\000n\000g\000e\000s}{section.8}% 48
49+
\BOOKMARK [2][-]{subsection.8.4}{\376\377\000S\000u\000b\000m\000o\000d\000u\000l\000e\000s}{section.8}% 49
50+
\BOOKMARK [1][-]{section.9}{\376\377\000U\000s\000i\000n\000g\000\040\000G\000i\000t\000H\000u\000b}{}% 50
51+
\BOOKMARK [2][-]{subsection.9.1}{\376\377\000R\000e\000a\000d\000M\000e}{section.9}% 51
52+
\BOOKMARK [2][-]{subsection.9.2}{\376\377\000C\000r\000e\000a\000t\000i\000n\000g\000\040\000R\000e\000l\000e\000a\000s\000e\000s}{section.9}% 52
53+
\BOOKMARK [2][-]{subsection.9.3}{\376\377\000C\000r\000e\000a\000t\000i\000n\000g\000\040\000I\000s\000s\000u\000e\000s}{section.9}% 53
54+
\BOOKMARK [1][-]{section.10}{\376\377\000C\000o\000n\000c\000l\000u\000s\000i\000o\000n}{}% 54

Git Tutorial.pdf

7.47 KB
Binary file not shown.

Git Tutorial.synctex.gz

14.1 KB
Binary file not shown.

Git Tutorial.tex

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,27 @@
405405
\includegraphics[scale=0.9]{Git Tree}
406406
\end{figure}
407407

408-
\subsection{Combining Commits}
409-
The final way we can manipulate commits at the intermediate level is to combine them or "squash" the commits. There are two main ways to do this. The more advanced way is using rebasing, which I will talk about in the section on advanced usage of git. The easier and more typical way to squashing is to add the \colorbox{light-gray}{\textbf{- -squash}} flag when using \colorbox{light-gray}{\textbf{git merge}}. This will take all of the commits you have done in that branch and then combine them together on the merge. You can also do this manually in GitHub when merging there or submitting a Pull Request, which I will talk about later. You can also squash the last several commits by using \colorbox{light-gray}{\textbf{git reset --soft}} followed by the reference to the commit you want to go back to so you can commit again with all of the files together.
408+
\subsection{Combining Commits}
409+
The final way we can manipulate commits at the intermediate level is to combine them or "squash" the commits. There are two main ways to do this. The more advanced way is using rebasing, which I will talk about in the section on advanced usage of git. The easier and more typical way to squashing is to add the \colorbox{light-gray}{\textbf{- -squash}} flag when using \colorbox{light-gray}{\textbf{git merge}}. This will take all of the commits you have done in that branch and then combine them together on the merge. You can also do this manually in GitHub when merging there or submitting a Pull Request, which I will talk about later. You can also squash the last several commits by using \colorbox{light-gray}{\textbf{git reset --soft}} followed by the reference to the commit you want to go back to so you can commit again with all of the files together.
410410

411-
\subsection{Bisect}
412-
The final intermediate command is \colorbox{light-gray}{\textbf{git bisect}}. Using bisect allows you to do a binary search through your commit history to find the moment your code stopped working or a change was made. to start the search, type \colorbox{light-gray}{\textbf{git bisect start}}. This will go to the middle commit of the history. If the code still works, you type \colorbox{light-gray}{\textbf{git bisect good}} to move earlier in the history when searching and type \colorbox{light-gray}{\textbf{git bisect bad}} if the current commit still has broken code. Following this process, you will quickly be directed to the commit that broke your code.
413-
411+
\subsection{Bisect}
412+
The final intermediate command is \colorbox{light-gray}{\textbf{git bisect}}. Using bisect allows you to do a binary search through your commit history to find the moment your code stopped working or a change was made. to start the search, type \colorbox{light-gray}{\textbf{git bisect start}}. This will go to the middle commit of the history. If the code still works, you type \colorbox{light-gray}{\textbf{git bisect good}} to move earlier in the history when searching and type \colorbox{light-gray}{\textbf{git bisect bad}} if the current commit still has broken code. Following this process, you will quickly be directed to the commit that broke your code.
413+
414+
\section{Advanced Usage of Git}
415+
This last section on the Usage of git are more advanced techniques that I have at least used on occasion, but are by no means the full extent on all of the other things you can do with git. I may need to make use of the things in this section a couple times a year or in special cases.
416+
417+
\subsection{Rebasing}
418+
Rebasing is a powerful technique that allows you to drastically alter your commit history in multiple ways. If you enter the command \colorbox{light-gray}{\textbf{git rebase -i}} followed by a reference to how far back in the commit history you want to go, the terminal will change to a screen that uses vim that allows you to do mulitple commands listed at the bottom of the screen. On screen you will see a list of commits with their SHA values and to the left of each commit will be a keyword. By default the keyword will be pick. This keyword says that you want to change the messages of those commits. Another common keyword is drop. This tells the rebase that you want to delete those commits. \textbf{Only do this if you know everything in those commits is something you want to delete.} The final common keyword is squash. Like before, using squash will take all of those commits and combine them together. You will also have the option of changing the combined commit message or allow it to default to a list of all the commit messages. The last main usage of rebasing that I use is you can rearrange you commits on screen if you find a specific reason to. For example, you may want to group commits by the things they change. Beware of doing this if the commits work on the same files as you may accidentally revert a change. When you are done, you write and quit like usual and the rebasing will take effect. If you picked options that affect commit messages, you will keep getting screens where you can change the commit messages one by one in order of the commits on the rebasing screen.
419+
420+
\subsection{Cherry-picking}
421+
Cherry-picking is a technique to take important commits out of other branches and make copies of them in your current branch. Lets say there is a case where someone is working on a feature and they find a way to fix a bug in the main code. They may not be done with the feature addition, but you want the fix as soon as possible. to accomplish this, they can commit the bug fix in their branch and you can "cherry-pick" or make a copy of that commit in the main branch by using \colorbox{light-gray}{\textbf{git cherry-pick}} followed by the commit's SHA value. This will leave the original commit in the feature branch and a copy in the main branch. Then the feature is merged in, that commit will be skipped over in the merge. For a more in-depth look at cherry-picking, refer to this \href{https://www.atlassian.com/git/tutorials/cherry-pick}{guide} from Atlassian.
422+
423+
\subsection{Stashing Incomplete Changes}
424+
Lets say you are in a situation where you are working on some changes locally, but you don't think they are ready for a commit. You need to pull new changes from the central, remote repository or merge in a branch, but to do so would require to to either commit your changes or delete them. Instead, you can "stash" or save these changes using \colorbox{light-gray}{\textbf{git stash}} when you want to bring the changes back, use \colorbox{light-gray}{\textbf{git stash pop}}. You can also make multiple stashes and give them names using \colorbox{light-gray}{\textbf{git stash save}} followed by a name. You can then list the stashes using \colorbox{light-gray}{\textbf{git stash list}} and apply stashed changes back to the repository using \colorbox{light-gray}{\textbf{git stash apply}} followed by the index number of the stashed changes from the list.
425+
426+
\subsection{Submodules}
427+
The final advanced technique I want to mention is using submodules. In a nutshell, using submodules allows you to clone a reference to a repository inside of another repository. When pulling the main repository, you will also be able to pull your submodules. The real strength of this in the lab is we can use shared repositories for tools, modeling, or supporting scripts that can be pulled inside of individual, experiment repositories, but all version controlled from the same place.
428+
414429

415430
\section{Using GitHub}
416431
There are three main reasons to directly go to GitHub instead of using the terminal or your GUI: to make the README, create a release, manage an issue.

Git Tutorial.toc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,13 @@
4242
\contentsline {subsubsection}{\numberline {7.2.3}Relative Referencing from HEAD}{17}{subsubsection.7.2.3}%
4343
\contentsline {subsection}{\numberline {7.3}Combining Commits}{18}{subsection.7.3}%
4444
\contentsline {subsection}{\numberline {7.4}Bisect}{19}{subsection.7.4}%
45-
\contentsline {section}{\numberline {8}Using GitHub}{19}{section.8}%
46-
\contentsline {subsection}{\numberline {8.1}ReadMe}{19}{subsection.8.1}%
47-
\contentsline {subsection}{\numberline {8.2}Creating Releases}{20}{subsection.8.2}%
48-
\contentsline {subsection}{\numberline {8.3}Creating Issues}{20}{subsection.8.3}%
49-
\contentsline {section}{\numberline {9}Conclusion}{21}{section.9}%
45+
\contentsline {section}{\numberline {8}Advanced Usage of Git}{19}{section.8}%
46+
\contentsline {subsection}{\numberline {8.1}Rebasing}{19}{subsection.8.1}%
47+
\contentsline {subsection}{\numberline {8.2}Cherry-picking}{19}{subsection.8.2}%
48+
\contentsline {subsection}{\numberline {8.3}Stashing Incomplete Changes}{20}{subsection.8.3}%
49+
\contentsline {subsection}{\numberline {8.4}Submodules}{20}{subsection.8.4}%
50+
\contentsline {section}{\numberline {9}Using GitHub}{20}{section.9}%
51+
\contentsline {subsection}{\numberline {9.1}ReadMe}{20}{subsection.9.1}%
52+
\contentsline {subsection}{\numberline {9.2}Creating Releases}{21}{subsection.9.2}%
53+
\contentsline {subsection}{\numberline {9.3}Creating Issues}{22}{subsection.9.3}%
54+
\contentsline {section}{\numberline {10}Conclusion}{22}{section.10}%

0 commit comments

Comments
 (0)