|
37 | 37 | <div class="body">
|
38 | 38 | <h1>GitHub</h1><strong>Prerequisites:</strong> <a href=
|
39 | 39 | "../intro-to-git/">Intro to Git</a>
|
40 |
| - <h2 id="Resources">Resources</h2> |
| 40 | + <h2 id="Setup">Setup</h2> |
| 41 | + <p>Create an account on <a href="https://github.com/">GitHub</a>.</p> |
| 42 | + <h3 id="Create_SSH_key_pair">Create SSH key pair</h3> |
| 43 | + <pre>ssh-keygen -t rsa -b 4096 -C " [email protected]" </pre> |
| 44 | + <p>See <a href= |
| 45 | + "https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent"> |
| 46 | + this</a> for more.</p> |
| 47 | + <h3 id="Add_public_key_to_GitHub">Add public key to GitHub</h3> |
| 48 | + <pre>cat ~/.ssh/id_rsa.pub</pre> |
| 49 | + <p>Copy the entire block, then follow the instructions <a href= |
| 50 | + "https://docs.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account"> |
| 51 | + here</a> to add it to your account.</p> |
| 52 | + <h2 id="Usage">Usage</h2> |
| 53 | + <p>To push an updated commit, it's best to use this command to not |
| 54 | + overwrite a teammates commit. If you cannot push by running this command |
| 55 | + then update your local repo by pulling and rebasing, then run this command |
| 56 | + again.</p> |
| 57 | + <pre>git push --force-with-lease</pre> |
| 58 | + <h3 id="New_patchset">New patchset</h3> |
| 59 | + <p>Make sure new patchsets are created with <code>git commit</code>. Using |
| 60 | + <code>git commit --amend</code> will change a commit already merged |
| 61 | + upstream and lead to conflicts. Commit messages should have a format like |
| 62 | + this:</p> |
| 63 | + <pre>Implement a thing |
| 64 | + |
| 65 | +Optional extended description that should be complete sentences. |
| 66 | + |
| 67 | +Fixes #42.</pre> |
| 68 | + <p>where <code>42</code> would be the issue number being closed by this PR. |
| 69 | + The last line ensures the issue is automatically closed when the PR is |
| 70 | + merged. Make sure each issue resolution is a separate branch and PR.</p> |
| 71 | + <h3 id="Revisions_to_patchset">Revisions to patchset</h3> |
| 72 | + <p>Any changes should be incorporated into the commit previously pushed by |
| 73 | + either amending or rebasing (not pushing a new commit on top of the old |
| 74 | + one). Gerrit tracks the revisions using the "Change-Id" line at the bottom |
| 75 | + of the commit message. <i>Make sure this line does not change and remains |
| 76 | + the last line</i> during commit message modifications. Otherwise, a new |
| 77 | + patchset will be created instead.</p> |
| 78 | + <p>Verify this was done correctly by inspecting the output of <code>git log |
| 79 | + main..HEAD</code>. There should be only one commit listed and its Change-Id |
| 80 | + should match the old one.</p> |
| 81 | + <h4 id="Uncommitted_changes">Uncommitted changes</h4> |
| 82 | + <pre>git commit --amend</pre> |
| 83 | + <h4 id="Squashing_committed_changes">Squashing committed changes</h4> |
| 84 | + <p>If a new commit or commits were made while working, they should be |
| 85 | + squashed into the first before submitting it all as a new revision. To do |
| 86 | + so, run</p> |
| 87 | + <pre>git rebase -i <commit hash before your commits></pre> |
| 88 | + <p>The first commit in the resulting generated file should be set to "r" |
| 89 | + for "reword" if the commit message needs to be altered to include parts of |
| 90 | + the other two commits. The other commits should be set to "f" for "fixup" |
| 91 | + so their contents are squashed into the first commit. <code>git |
| 92 | + rebase</code> descriptions for other options are in the file comment.</p> |
| 93 | + <h2 id="Git_.28advanced_usage.29_lecture_notes">Git (advanced usage) |
| 94 | + lecture notes</h2> |
41 | 95 | <ul>
|
42 |
| - <li> |
43 |
| - <a href="https://github.com/frc3512/">GitHub</a> - mirrors of the code |
44 |
| - we've written for the robotics team reside here. |
45 |
| - </li> |
46 |
| - <li>Git's <a href="https://git-scm.com/doc/">online documentation</a>. |
47 |
| - </li> |
48 |
| - <li>Git (advanced usage) lecture <a href="lecture/">slides</a>. |
49 |
| - </li> |
50 |
| - <li> |
51 |
| - <a href= |
52 |
| - "https://tom.preston-werner.com/2009/05/19/the-git-parable.html">The |
53 |
| - Git Parable</a> - an alternate explanation of Git terminology. |
54 |
| - </li> |
55 |
| - <li> |
56 |
| - <a href="https://chris.beams.io/posts/git-commit/">How and why to write |
57 |
| - a good commit message</a> |
58 |
| - </li> |
59 |
| - <li> |
60 |
| - <a href= |
61 |
| - "https://github.com/k88hudson/git-flight-rules/blob/master/README.md">Flight |
62 |
| - rules for Git</a>: solutions to common problems. |
63 |
| - </li> |
64 |
| - <li> |
65 |
| - <a href= |
66 |
| - "https://github.com/pluralsight/git-internals-pdf/releases/tag/v2.0">PDF |
67 |
| - on Git internals</a> for those curious about how Git stores files and |
68 |
| - revisions. |
| 96 | + <li>Git (advanced usage) lecture <a href="lecture/">slides</a> |
69 | 97 | </li>
|
70 | 98 | </ul>
|
71 |
| - <h2 id="Git_.28advanced_usage.29_lecture_notes">Git (advanced usage) |
72 |
| - lecture notes</h2> |
73 | 99 | <h3 id="Versioning">Versioning</h3>
|
74 | 100 | <ul>
|
75 | 101 | <li>Easily get commit later? (tag)</li>
|
@@ -139,59 +165,6 @@ <h3 id="Nuclear_option_for_binary_files">Nuclear option for binary
|
139 | 165 | <li><code>git filter-branch --tree-filter 'rm -f largeFile.out'
|
140 | 166 | HEAD</code></li>
|
141 | 167 | </ul>
|
142 |
| - <h2 id="Setup">Setup</h2> |
143 |
| - <p>Create an account on <a href="https://github.com/">GitHub</a>.</p> |
144 |
| - <h3 id="Create_SSH_key_pair">Create SSH key pair</h3> |
145 |
| - <pre>ssh-keygen -t rsa -b 4096 -C " [email protected]" </pre> |
146 |
| - <p>See <a href= |
147 |
| - "https://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent"> |
148 |
| - this</a> for more.</p> |
149 |
| - <h3 id="Add_public_key_to_GitHub">Add public key to GitHub</h3> |
150 |
| - <pre>cat ~/.ssh/id_rsa.pub</pre> |
151 |
| - <p>Copy the entire block, then follow the instructions <a href= |
152 |
| - "https://docs.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account"> |
153 |
| - here</a> to add it to your account.</p> |
154 |
| - <h2 id="Usage">Usage</h2> |
155 |
| - <p>In Gerrit, features are submitted in branches with one commit per |
156 |
| - branch. Give each branch a name reflecting its content for easier |
157 |
| - management. Submit new patchsets and revisions of existing patchsets via |
158 |
| - the following command.</p> |
159 |
| - <pre>git push --force-with-lease</pre> |
160 |
| - <h3 id="New_patchset">New patchset</h3> |
161 |
| - <p>Make sure new patchsets are created with <code>git commit</code>. Using |
162 |
| - <code>git commit --amend</code> will change a commit already merged |
163 |
| - upstream and lead to conflicts. Commit messages should have a format like |
164 |
| - this:</p> |
165 |
| - <pre>Implement a thing |
166 |
| - |
167 |
| -Optional extended description that should be complete sentences. |
168 |
| - |
169 |
| -Fixes #42.</pre> |
170 |
| - <p>where <code>42</code> would be the issue number being closed by this PR. |
171 |
| - The last line ensures the issue is automatically closed when the PR is |
172 |
| - merged. Make sure each issue resolution is a separate branch and PR.</p> |
173 |
| - <h3 id="Revisions_to_patchset">Revisions to patchset</h3> |
174 |
| - <p>Any changes should be incorporated into the commit previously pushed by |
175 |
| - either amending or rebasing (not pushing a new commit on top of the old |
176 |
| - one). Gerrit tracks the revisions using the "Change-Id" line at the bottom |
177 |
| - of the commit message. <i>Make sure this line does not change and remains |
178 |
| - the last line</i> during commit message modifications. Otherwise, a new |
179 |
| - patchset will be created instead.</p> |
180 |
| - <p>Verify this was done correctly by inspecting the output of <code>git log |
181 |
| - main..HEAD</code>. There should be only one commit listed and its Change-Id |
182 |
| - should match the old one.</p> |
183 |
| - <h4 id="Uncommitted_changes">Uncommitted changes</h4> |
184 |
| - <pre>git commit --amend</pre> |
185 |
| - <h4 id="Squashing_committed_changes">Squashing committed changes</h4> |
186 |
| - <p>If a new commit or commits were made while working, they should be |
187 |
| - squashed into the first before submitting it all as a new revision. To do |
188 |
| - so, run</p> |
189 |
| - <pre>git rebase -i <commit hash before your commits></pre> |
190 |
| - <p>The first commit in the resulting generated file should be set to "r" |
191 |
| - for "reword" if the commit message needs to be altered to include parts of |
192 |
| - the other two commits. The other commits should be set to "f" for "fixup" |
193 |
| - so their contents are squashed into the first commit. <code>git |
194 |
| - rebase</code> descriptions for other options are in the file comment.</p> |
195 | 168 | <h2 id="Useful_Git_features">Useful Git features</h2>
|
196 | 169 | <ul>
|
197 | 170 | <li>End-of-line conversion (crlf or eol)</li>
|
|
0 commit comments