-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgit_tutorial_notes1.html
More file actions
572 lines (546 loc) · 30.8 KB
/
Copy pathgit_tutorial_notes1.html
File metadata and controls
572 lines (546 loc) · 30.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.2.269">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>git_tutorial_notes</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1.6em;
vertical-align: middle;
}
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { color: #008000; } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { color: #008000; font-weight: bold; } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>
<script src="git_tutorial_notes1_files/libs/clipboard/clipboard.min.js"></script>
<script src="git_tutorial_notes1_files/libs/quarto-html/quarto.js"></script>
<script src="git_tutorial_notes1_files/libs/quarto-html/popper.min.js"></script>
<script src="git_tutorial_notes1_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="git_tutorial_notes1_files/libs/quarto-html/anchor.min.js"></script>
<link href="git_tutorial_notes1_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="git_tutorial_notes1_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="git_tutorial_notes1_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="git_tutorial_notes1_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="git_tutorial_notes1_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
</head>
<body class="fullcontent">
<div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
<main class="content" id="quarto-document-content">
<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title">git_tutorial_notes</h1>
</div>
<div class="quarto-title-meta">
</div>
</header>
<section id="getting-started-with-github-git-and-r-studio." class="level1">
<h1>Getting started with github, git and R-studio.</h1>
<section id="creating-a-github-account" class="level3">
<h3 class="anchored" data-anchor-id="creating-a-github-account">Creating a github account</h3>
<p>Go to the github <a href="http://github.com">website</a></p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/1.PNG" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Github website</figcaption><p></p>
</figure>
</div>
<p>and signup with your email and password.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/2.PNG" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Github signup</figcaption><p></p>
</figure>
</div>
<p>Once you have a github site, in the upper left hand corner on your github site create a repository for where you want files from your pending project to go. Name the repository whatever you will be calling your project. Select to have a readme file where you can post notes about the project. Select to make it private while you are working on int (this can be changed later).</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/3.PNG" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Github new repository</figcaption><p></p>
</figure>
</div>
<p>Once you hit create you new repository should look something like this:</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/4.PNG" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">terminal git version</figcaption><p></p>
</figure>
</div>
</section>
<section id="getting-started-with-git-on-your-computer" class="level2">
<h2 class="anchored" data-anchor-id="getting-started-with-git-on-your-computer">Getting started with git on your computer</h2>
<p>Check if you have git installed on your computer. For this you have to use terminal to check. In your terminal write</p>
<p>git –version</p>
<p>and you should get back your version number.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/8.PNG" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">terminal git version</figcaption><p></p>
</figure>
</div>
<p>If you do not have git on your computer you may have to install it. For instructions on how to check and install git on your computer see this very helpful <a href="https://jennybc.github.io/2014-05-12-ubc/ubc-r/session03_git.html">website</a> or better yet this <a href="https://happygitwithr.com/index.html">manual</a></p>
</section>
<section id="setting-up-your-project-in-r-studio" class="level2">
<h2 class="anchored" data-anchor-id="setting-up-your-project-in-r-studio">Setting up your project in R studio</h2>
<p>Now that you have a github account and a local git on your computer you are ready to start working with git through R studio.</p>
<p>Open R-studio and start a new project. Choose a project with version control:</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/5.PNG" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Creating a version control project</figcaption><p></p>
</figure>
</div>
<p>Select the option to clone a repository from git. What R studio will then do is to clone the repository you created on github locally on your computer.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/6.PNG" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Cloning the git repository</figcaption><p></p>
</figure>
</div>
<p>So that R-studio knows which github local repository to clone you have to specify an external url that matches your username and the name of the new repository that you just created on github (Repository URL).</p>
<p>You also have to specify where your local git files are going to be located see (Create project as subdirectory of:).</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/7.PNG" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Specifying location of external and local repositories</figcaption><p></p>
</figure>
</div>
<p>Hit the create button and R studio will create a project site that should look something like this. Notice how the files replicate what is in</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/9.PNG" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">local files replicating external repository files</figcaption><p></p>
</figure>
</div>
<p>In case you run into trouble at this stage - and are not able to connect your files make sure that your local credentials (signup email matches the email you used to signup with github). To check this you can use:</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(usethis)</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">edit_git_config</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stderr">
<pre><code>• Edit '/Users/hannahbirnir/.gitconfig'</code></pre>
</div>
</div>
<p>Remember that you have to install the “usethis” package if it is not already on your computer.</p>
<p>If your git and hub have no problems communicating you can set about modifying your local files at will, adding files and changing them.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/10.PNG" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Modifying local files</figcaption><p></p>
</figure>
</div>
<p>Each time you add a new file in your local directory or change it in some way it will appear in your git tab like so:</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/11.PNG" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Local files in Git tab</figcaption><p></p>
</figure>
</div>
<p>Notice that because I have not modified the README file that was imported from github this file does not appear in my git tab.</p>
</section>
<section id="pushing-files" class="level2">
<h2 class="anchored" data-anchor-id="pushing-files">Pushing files</h2>
<p>The final step is to commit the changes I have made to my local files to the github repository. For this purpose I have to commit the files I want to update (I only commit the files I wish to update) and then I need to push them to the external repository.</p>
<p>To do this I first select the files that I want to commit. Next I hit the commit button.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/12.PNG" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Local files in Git tab</figcaption><p></p>
</figure>
</div>
<p>When I hit the commit button another window pops up where I can write myself notes about the changes I am committing.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/13.PNG" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Commit notes</figcaption><p></p>
</figure>
</div>
<p>Once I hit commit R-studio knows which local files I want to change in my external depository. Note that I can work locally and commit many files and then work on other files and commit them later. <strong>Commit only commits changes to my files locally.</strong> The last step then is to push all my locally committed files to my external repository.</p>
<p>From within my project I simply push the push button in my now empty git tab and my external repository is updated.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/14.PNG" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Pushing changes to github</figcaption><p></p>
</figure>
</div>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/15.PNG" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Updated external repository</figcaption><p></p>
</figure>
</div>
<p>Github then tracks all of the changes in each file and new files added in each commit while also updating the main file.</p>
<p>This is very nice if you are working on a project - like a website that you might want to change frequently. You can simply open the project - make a change to any one part of the project and commit those changes to github. Imagine, for example, a website where you post new data and other information as it becomes available.</p>
</section>
</section>
<section id="exercise" class="level1">
<h1>Exercise</h1>
<section id="install-git-on-your-computer" class="level3">
<h3 class="anchored" data-anchor-id="install-git-on-your-computer">Install git on your computer</h3>
</section>
<section id="create-a-github-account" class="level3">
<h3 class="anchored" data-anchor-id="create-a-github-account">Create a github account</h3>
</section>
<section id="create-a-version-control-project-in-r-studio-and-upload-it-to-github" class="level3">
<h3 class="anchored" data-anchor-id="create-a-version-control-project-in-r-studio-and-upload-it-to-github">Create a version control project in R studio and upload it to Github</h3>
</section>
</section>
<section id="working-together-in-git." class="level1">
<h1>Working together in git.</h1>
<p>One of the most useful things about github is the ability to work collaboratively.</p>
<section id="associating-your-rstudio-with-a-collaborative-project" class="level2">
<h2 class="anchored" data-anchor-id="associating-your-rstudio-with-a-collaborative-project">Associating your RStudio with a collaborative project</h2>
<p>First, in order to work collaboratively, you may need to associate your RStudio with a project in GitHub that you did not create. If you created the project, do the following to add collaborators:</p>
<p>Go on the Github website to Settings > Manage Access > Invite a collaborator.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/16.PNG" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Inviting Github Collaborations</figcaption><p></p>
</figure>
</div>
<p>Your teammate should accept the invite in their email.</p>
<p>Once this is complete, you can use the steps above to associate your RStuido with the GitHub project.</p>
</section>
<section id="pulling-changes" class="level2">
<h2 class="anchored" data-anchor-id="pulling-changes">Pulling Changes</h2>
<p>One important aspect of collaboration in Github is the ability to pull changes. This allows you to update your code to align with changes pushed by collaborators.</p>
<p>Using the down arrow button, RStudio goes to the GitHub repo, grabs the most recent code and brings it into your local editor. (Pulling regularly is extremely important if you’re collaborating, though if you’re the only one working on an RStudio project and associated GitHub repo, you know your local code matches what’s on GitHub so it’s less important.)</p>
<p>To pull, click the blue down arrow on your Git tab to see if you have changes to pull. If collaborating, you might run into merge conflicts.</p>
<p>When you pull your project updates to show the changes your collaborator has made to the project. Look at the dates.</p>
<p><img src="figures/18.png" class="img-fluid"></p>
<p>and</p>
<p><img src="figures/19.png" class="img-fluid"> You can also track the changes on github if you want more details.</p>
<p>Go to your github project:</p>
<p><img src="figures/20.png" class="img-fluid"> There you see who are the collaborators and when each item was updated. For even more information click on any of the files (here the qmd file)</p>
<p><img src="figures/21.png" class="img-fluid"> Here you see the history of the development of the project and if you want to see who made what changes when push the blame button.</p>
<p><img src="figures/22.png" class="img-fluid"> The blame allows you to blame whoever - mostly yourself ;) is responsible for making changes to your project.</p>
<p>If you want more of an overview - then push the history button and you get a summary of changes:</p>
<p><img src="figures/23.png" class="img-fluid"> In sum this is the workflow when you and your collaborator are both working on the main project and either one of you can make changes to the project.</p>
<p>When someone invites you to a project and to work on the main as here:</p>
<p><img src="figures/30.png" class="img-fluid"></p>
<p>You can open the project locally as you would any other version control project (see earlier steps in the tutorial)</p>
<p><img src="figures/31.png" class="img-fluid"></p>
<p>Once you are done changing your files locally - you then go through the same steps of committing and pushing. Which results in this message telling you the process was successful.</p>
<p><img src="figures/32.png" class="img-fluid"></p>
<p>aand your changes will show up in the remote directory on github.</p>
<p><img src="figures/33.png" class="img-fluid"></p>
</section>
<section id="branches" class="level2">
<h2 class="anchored" data-anchor-id="branches">Branches</h2>
<p>Sometimes you have a hirearchy - when one of you is the lead (author for example, or if you are working with an RA etc). where you want to review and approve any changes before they are made. In those cases you work with branches.</p>
<p>In order to create new branches, go to the ‘git’ tab on your RStudio console and click ‘new branch’.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/16.5.png" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Creating a New Branch</figcaption><p></p>
</figure>
</div>
<p>You can then populate that branch the way you want and ask your associate to work on that branch only (your associate can also create a branch to be reviewed later)</p>
<p><img src="figures/17.png" class="img-fluid"></p>
<p>Then click create and you have made the new branch.</p>
<p>You can see your branches like so:</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="figures/24.png" class="img-fluid figure-img"></p>
<p></p><figcaption class="figure-caption">Seeing Branches</figcaption><p></p>
</figure>
</div>
<p>Then simply create the new branch and you’re done.</p>
<p>If you click on the new branch, you will then see this as you switch:</p>
<p><img src="figures/25.png" class="img-fluid"></p>
<p>This branch will initially not be published to the repo. You can publish it via the github website or the github desktop client.</p>
<p>You will then see this on your github page:</p>
<p><img src="figures/26.png" class="img-fluid"></p>
</section>
</section>
<section id="exercises" class="level1">
<h1>Exercises</h1>
<section id="start-a-github-project-with-some-documents" class="level3">
<h3 class="anchored" data-anchor-id="start-a-github-project-with-some-documents">Start a github project with some documents</h3>
</section>
<section id="invite-your-partner-to-join" class="level3">
<h3 class="anchored" data-anchor-id="invite-your-partner-to-join">Invite your partner to join</h3>
</section>
<section id="pull-your-partners-documents" class="level3">
<h3 class="anchored" data-anchor-id="pull-your-partners-documents">Pull your partner’s documents,</h3>
</section>
<section id="edit-the-documents-commit-the-changes-and-push-changes-to-their-project" class="level3">
<h3 class="anchored" data-anchor-id="edit-the-documents-commit-the-changes-and-push-changes-to-their-project">Edit the documents, commit the changes and push changes to their project</h3>
</section>
</section>
<section id="troubleshooting-unintended-branches" class="level1">
<h1>Troubleshooting unintended branches</h1>
<p>If you try to push when you have not pulled changes that your collaborator has made on a main branch you get the following message:</p>
<p><img src="figures/34.png" class="img-fluid"></p>
<p>If you try to pull before pushing changes that you have made to documents that your collaborator has changed you get the following warning</p>
<p><img src="figures/35.png" class="img-fluid"></p>
<p>Here the program is creating branches for you so that changes are not lost. The solution to #1 is to pull before you start making ay changes to make sure you are working on the most up to date version. The solution to #2 when you both have made changes that need to be reconciled is to</p>
<ol type="a">
<li>Committ your local changes then you receive the following message:</li>
</ol>
<p><img src="figures/36.png" class="img-fluid"></p>
<p>then you pick from the options merge rebase and fast-forward</p>
<p>for a detailed explanation of the differences between the different options see for example this <a href="https://frontend.turing.edu/lessons/module-3/merge-vs-rebase.html?ads_cmpid=6451354298&ads_adid=76255849919&ads_matchtype=&ads_network=g&ads_creative=517671727591&utm_term=&ads_targetid=dsa-19959388920&utm_campaign=&utm_source=adwords&utm_medium=ppc&ttv=2&gclid=CjwKCAiAoL6eBhA3EiwAXDom5hB7rNI86O5HQq3UFkG9tY7t8uBDicj5fL9lc9K_JCyjvZYKz-Wm-RoC97kQAvD_BwE">website</a></p>
<p>To employ the merge solution go to terminal and write:</p>
<p><img src="figures/37.png" class="img-fluid"></p>
<p>then you can pull the document. Once you pull the document you can scroll through and see where your merger conflict occurred.</p>
<p><img src="figures/38.png" class="img-fluid"></p>
<p>You then have to resolve this conflict save and now you can push.</p>
</section>
<section id="good-git-hygene" class="level1">
<h1>Good git hygene</h1>
<p>You can look to this <a href="https://betterprogramming.pub/six-rules-for-good-git-hygiene-5006cf9e9e2">article</a> for other useful information for keeping good Git hygiene when collaborating.</p>
<p>Briefly the first four rules of thumb are:</p>
<section id="always-pull-before-a-push" class="level3">
<h3 class="anchored" data-anchor-id="always-pull-before-a-push"><strong>Always Pull Before a Push</strong></h3>
<section id="pull-frequently" class="level4">
<h4 class="anchored" data-anchor-id="pull-frequently"><strong>Pull frequently</strong></h4>
</section>
<section id="push-infrequently" class="level4">
<h4 class="anchored" data-anchor-id="push-infrequently"><strong>Push infrequently</strong></h4>
</section>
<section id="commit-frequently" class="level4">
<h4 class="anchored" data-anchor-id="commit-frequently"><strong>Commit Frequently</strong></h4>
<p>Additionally the <a href="https://betterprogramming.pub/six-rules-for-good-git-hygiene-5006cf9e9e2">article</a> discusses optimal git branch for working together.</p>
</section>
<section id="merge-forward-frequently" class="level4">
<h4 class="anchored" data-anchor-id="merge-forward-frequently"><strong>Merge “forward” frequently</strong></h4>
</section>
<section id="create-pull-requests-infrequently" class="level4">
<h4 class="anchored" data-anchor-id="create-pull-requests-infrequently"><strong>Create Pull Requests Infrequently</strong></h4>
<p>To better understand these</p>
</section>
</section>
</section>
<section id="associating-existing-r-studio-projects-with-git" class="level1">
<h1>Associating existing r studio projects with git</h1>
<p>In order to associate an existing RStudio project with Git you will need to create a Git repository as described above and then follow the steps below.</p>
<div class="cell">
<div class="cell-output cell-output-stderr">
<pre><code>✔ Setting active project to '/Users/hannahbirnir/Dropbox/Classes/2023/729B/
Github/Git_tutorial/git_tutorial'</code></pre>
</div>
</div>
<p>You will then get a prompt asking if you want to commit the files you’ve already created to your repo. Select yes (option 1). You should then also see the git tab.</p>
<div class="cell">
<div class="cell-output cell-output-stderr">
<pre><code>• Call `gitcreds::gitcreds_set()` to register this token in the local Git credential store
It is also a great idea to store this token in any password-management software that you use
• Open URL 'https://github.com/settings/tokens/new?scopes=repo,user,gist,workflow&description=DESCRIBE THE TOKEN\'S USE CASE'</code></pre>
</div>
</div>
<p>You will then get a number of options to select about what your token use case will be. This will be project-dependent.</p>
<p>You can learn more about the selections [here](https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps) to help guide you in your process.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="co">#library(gitcreds) </span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="co">#gitcreds_set()</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>When prompted to enter a token or password, enter the token you just created. If you have entered one previously, you will be prompted to choose if you’d like to keep your credentials. If nothing has changed, select 1 and keep things as they are. If they have, follow the most applicable selection.</p>
</section>
<section id="optional-github-desktop-client" class="level1">
<h1>Optional: Github Desktop Client</h1>
<p>A lot of problems can be resolved by examining the Github desktop client. It’s free and you can download it from the Github website.</p>
</section>
</main>
<!-- /main column -->
<script id="quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
const toggleBodyColorMode = (bsSheetEl) => {
const mode = bsSheetEl.getAttribute("data-mode");
const bodyEl = window.document.querySelector("body");
if (mode === "dark") {
bodyEl.classList.add("quarto-dark");
bodyEl.classList.remove("quarto-light");
} else {
bodyEl.classList.add("quarto-light");
bodyEl.classList.remove("quarto-dark");
}
}
const toggleBodyColorPrimary = () => {
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
if (bsSheetEl) {
toggleBodyColorMode(bsSheetEl);
}
}
toggleBodyColorPrimary();
const icon = "";
const anchorJS = new window.AnchorJS();
anchorJS.options = {
placement: 'right',
icon: icon
};
anchorJS.add('.anchored');
const clipboard = new window.ClipboardJS('.code-copy-button', {
target: function(trigger) {
return trigger.previousElementSibling;
}
});
clipboard.on('success', function(e) {
// button target
const button = e.trigger;
// don't keep focus
button.blur();
// flash "checked"
button.classList.add('code-copy-button-checked');
var currentTitle = button.getAttribute("title");
button.setAttribute("title", "Copied!");
let tooltip;
if (window.bootstrap) {
button.setAttribute("data-bs-toggle", "tooltip");
button.setAttribute("data-bs-placement", "left");
button.setAttribute("data-bs-title", "Copied!");
tooltip = new bootstrap.Tooltip(button,
{ trigger: "manual",
customClass: "code-copy-button-tooltip",
offset: [0, -8]});
tooltip.show();
}
setTimeout(function() {
if (tooltip) {
tooltip.hide();
button.removeAttribute("data-bs-title");
button.removeAttribute("data-bs-toggle");
button.removeAttribute("data-bs-placement");
}
button.setAttribute("title", currentTitle);
button.classList.remove('code-copy-button-checked');
}, 1000);
// clear code selection
e.clearSelection();
});
function tippyHover(el, contentFn) {
const config = {
allowHTML: true,
content: contentFn,
maxWidth: 500,
delay: 100,
arrow: false,
appendTo: function(el) {
return el.parentElement;
},
interactive: true,
interactiveBorder: 10,
theme: 'quarto',
placement: 'bottom-start'
};
window.tippy(el, config);
}
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
for (var i=0; i<noterefs.length; i++) {
const ref = noterefs[i];
tippyHover(ref, function() {
// use id or data attribute instead here
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
try { href = new URL(href).hash; } catch {}
const id = href.replace(/^#\/?/, "");
const note = window.document.getElementById(id);
return note.innerHTML;
});
}
const findCites = (el) => {
const parentEl = el.parentElement;
if (parentEl) {
const cites = parentEl.dataset.cites;
if (cites) {
return {
el,
cites: cites.split(' ')
};
} else {
return findCites(el.parentElement)
}
} else {
return undefined;
}
};
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
for (var i=0; i<bibliorefs.length; i++) {
const ref = bibliorefs[i];
const citeInfo = findCites(ref);
if (citeInfo) {
tippyHover(citeInfo.el, function() {
var popup = window.document.createElement('div');
citeInfo.cites.forEach(function(cite) {
var citeDiv = window.document.createElement('div');
citeDiv.classList.add('hanging-indent');
citeDiv.classList.add('csl-entry');
var biblioDiv = window.document.getElementById('ref-' + cite);
if (biblioDiv) {
citeDiv.innerHTML = biblioDiv.innerHTML;
}
popup.appendChild(citeDiv);
});
return popup.innerHTML;
});
}
}
});
</script>
</div> <!-- /content -->
</body></html>