-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1275 lines (1220 loc) · 55.9 KB
/
index.html
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
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta name="author" content="Valentin Lucet" />
<title>Git and GitHub from the Terminal & RStudio: An Introduction</title>
<script src="index_files/header-attrs-2.25/header-attrs.js"></script>
<script src="index_files/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="index_files/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="index_files/bootstrap-3.3.7/js/bootstrap.min.js"></script>
<script src="index_files/navigation-1.1/tabsets.js"></script>
<script src="index_files/navigation-1.1/codefolding.js"></script>
<link href="index_files/magnific-popup-1.1.0/magnific-popup.css" rel="stylesheet" />
<script src="index_files/magnific-popup-1.1.0/jquery.magnific-popup.min.js"></script>
<link href="index_files/downcute-0.1/downcute.css" rel="stylesheet" />
<link href="index_files/downcute-0.1/downcute_fonts_embed.css" rel="stylesheet" />
<script src="index_files/downcute-0.1/downcute_styles.js"></script>
<script src="index_files/downcute-0.1/downcute.js"></script>
<script src="index_files/prism-1.22/prism.js"></script>
<script src="index_files/jqueryui-1.13.2/jquery-ui.min.js"></script>
<link href="index_files/tocify-1.9.1/jquery.tocify.css" rel="stylesheet" />
<script src="index_files/tocify-1.9.1/jquery.tocify.js"></script>
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("toc");
});
$(document).ready(function () {
$('.tabset-dropdown > .nav-tabs > li').click(function () {
$(this).parent().toggleClass('nav-tabs-open')
});
});
</script>
<!-- code folding -->
<script>
$(document).ready(function () {
window.initializeCodeFolding("show" === "show");
});
</script>
<!-- code download -->
<!-- tabsets dropdown -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
background: white;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "";
border: none;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs > li.active {
display: block;
}
.tabset-dropdown > .nav-tabs > li.active a {
padding: 0 15px !important;
}
.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
background-color: transparent;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}
.tabset-dropdown > .nav-tabs > li {
display: none;
margin-left: 0 !important;
}
</style>
</head>
<body class="preload">
<!-- downcute start -->
<div id="docute" class="Root theme-default">
<div class="Page layout-narrow">
<div class="Wrap">
<div class="Sidebar">
<div class="SidebarItems" id="toc">
<ul>
<li><a href="#preparation"
id="toc-preparation">Preparation</a></li>
<li><a href="#exercise-1-once-upon-a-commit"
id="toc-exercise-1-once-upon-a-commit">Exercise 1: Once upon
a commit…</a>
<ul>
<li><a href="#a-note-on-project-oriented-workflows"
id="toc-a-note-on-project-oriented-workflows">A note on
Project-oriented workflows</a></li>
<li><a href="#at-the-terminal" id="toc-at-the-terminal">At
the terminal</a></li>
<li><a href="#in-rstudio" id="toc-in-rstudio">In
RStudio</a></li>
<li><a href="#at-the-terminal-1"
id="toc-at-the-terminal-1">At the terminal</a></li>
<li><a href="#in-rstudio-1" id="toc-in-rstudio-1">In
Rstudio</a></li>
<li><a href="#at-the-terminal-2"
id="toc-at-the-terminal-2">At the terminal</a></li>
<li><a href="#in-rstudio-2" id="toc-in-rstudio-2">In
Rstudio</a></li>
<li><a href="#at-the-terminal-3"
id="toc-at-the-terminal-3">At the terminal</a></li>
<li><a href="#in-rstudio-3" id="toc-in-rstudio-3">In
Rstudio</a></li>
<li><a href="#at-the-terminal-4"
id="toc-at-the-terminal-4">At the terminal</a></li>
<li><a href="#in-rstudio-4" id="toc-in-rstudio-4">In
Rstudio</a></li>
<li><a href="#at-the-terminal-5"
id="toc-at-the-terminal-5">At the terminal</a></li>
<li><a href="#in-rstudio-5" id="toc-in-rstudio-5">In
Rstudio</a></li>
</ul></li>
<li><a
href="#exercise-2-all-roads-lead-to-github-how-to-add-a-remote"
id="toc-exercise-2-all-roads-lead-to-github-how-to-add-a-remote">Exercise
2: All roads lead to GitHub, how to add a remote</a>
<ul>
<li><a href="#at-the-terminal-6"
id="toc-at-the-terminal-6">At the terminal</a></li>
<li><a href="#in-rstudio-6" id="toc-in-rstudio-6">In
Rstudio</a></li>
</ul></li>
<li><a
href="#exercise-3-teamwork-makes-the-dream-work-or-collabaring-with-git"
id="toc-exercise-3-teamwork-makes-the-dream-work-or-collabaring-with-git">Exercise
3: Teamwork makes the dream work, or collabaring with
git</a>
<ul>
<li><a href="#at-the-terminal-7"
id="toc-at-the-terminal-7">At the terminal</a></li>
<li><a href="#in-rstudio-7" id="toc-in-rstudio-7">In
Rstudio</a></li>
</ul></li>
<li><a
href="#exercise-4-do-the-push-and-pull-or-the-git-workflow"
id="toc-exercise-4-do-the-push-and-pull-or-the-git-workflow">Exercise
4: (Do The) Push and Pull, or the git workflow</a>
<ul>
<li><a href="#at-the-terminal-8"
id="toc-at-the-terminal-8">At the terminal</a></li>
<li><a href="#in-rstudio-8" id="toc-in-rstudio-8">In
Rstudio</a></li>
<li><a href="#at-the-terminal-9"
id="toc-at-the-terminal-9">At the terminal</a></li>
<li><a href="#in-rstudio-9" id="toc-in-rstudio-9">In
Rstudio</a></li>
<li><a href="#at-the-terminal-10"
id="toc-at-the-terminal-10">At the terminal</a></li>
<li><a href="#in-rstudio-10" id="toc-in-rstudio-10">In
Rstudio</a></li>
</ul></li>
<li><a
href="#exercise-5-git-of-war-or-conflicts-and-how-to-resolve-them"
id="toc-exercise-5-git-of-war-or-conflicts-and-how-to-resolve-them">Exercise
5 Git of war, or conflicts and how to resolve them</a>
<ul>
<li><a href="#at-the-terminal-11"
id="toc-at-the-terminal-11">At the terminal</a></li>
<li><a href="#in-rstudio-11" id="toc-in-rstudio-11">In
Rstudio</a></li>
<li><a href="#at-the-terminal-12"
id="toc-at-the-terminal-12">At the terminal</a></li>
<li><a href="#in-rstudio-12" id="toc-in-rstudio-12">In
Rstudio</a></li>
<li><a href="#at-the-terminal-13"
id="toc-at-the-terminal-13">At the terminal</a></li>
<li><a href="#in-rstudio-13" id="toc-in-rstudio-13">In
Rstudio</a></li>
</ul></li>
<li><a
href="#exercise-6-the-tree-of-git-or-the-basics-of-branching"
id="toc-exercise-6-the-tree-of-git-or-the-basics-of-branching">Exercise
6: The tree of git, or the basics of branching</a>
<ul>
<li><a href="#at-the-terminal-14"
id="toc-at-the-terminal-14">At the terminal</a></li>
<li><a href="#in-rstudio-14" id="toc-in-rstudio-14">In
Rstudio</a></li>
<li><a href="#at-the-terminal-15"
id="toc-at-the-terminal-15">At the terminal</a></li>
<li><a href="#in-rstudio-15" id="toc-in-rstudio-15">In
Rstudio</a></li>
<li><a href="#at-the-terminal-16"
id="toc-at-the-terminal-16">At the terminal</a></li>
<li><a href="#in-rstudio-16" id="toc-in-rstudio-16">In
Rstudio</a></li>
<li><a href="#at-the-terminal-17"
id="toc-at-the-terminal-17">At the terminal</a></li>
<li><a href="#in-rstudio-17" id="toc-in-rstudio-17">In
Rstudio</a></li>
<li><a href="#demo-gitkraken" id="toc-demo-gitkraken">DEMO:
Gitkraken</a></li>
</ul></li>
</ul>
</div>
<div data-position="sidebar:post-end" class="InjectedComponents"><div class="dark-theme-toggler"><div class="toggle "><div class="toggle-track"><div class="toggle-track-check"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAA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lyFCkw0NJ5C0Ojv7zvT1a1WV1TuvZDdL4NTgB7CASYpsen6gqvG5jmTf5qHedADgkBl3D0nkSgNhZACDyi0FUKZRr3IdRjgN4WPPoFMIIegIK3mqd38fS80mcJKelM4szNyzZtQbkchGePuBRS8Eg9pHU8ojRQpSqs+ajAIwTjjUMQ/nvTNM0kicwYxZIYMh/891DYi+fvedB+c1xsm4lDU6ya+Axtz+RiAzEVYbajQOpq17F0R9QevNcEhfcU+xvyQQUalGJBSesqOkgPQ4YNyUZL9fSvUPDjoNAwN8/dwFjaczNkc3ptaMud1EIDtGcmXTcefO2cGSvKIFfp/2JIJxlq7xEl3nVPM4fDeIbPkD16/ptNc0bDu7qxbsu0R2JGywWMIjF2ft3tjfloAyQAGXiOn8hrqwbVvMXzaO+QeHXP6nF0wvX74Hf4NGG5GPjSlYoyM3P/0FbCT6zvM/yYoAAAAASUVORK5CYII=" role="presentation" style="pointer-events: none;" width="16" height="16"></div> <div class="toggle-track-x"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPg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fY2xOVOxFS8SK3Le0l48VyYu1M8HRe5JD8wKPTjYnifaK3Wfn/GChYQ8ZAi6WRzWgqLV5YrsVLnZaVSoXU1g9gOIDwFySiGi+Zdrnzr7J3r+SMuszlcQCRn8lNGcTuSy2jOI7o9mxjZo+vR3ej3tN+ifRSOyUTS0+VMOid93cCubeiy/6TImS0QxRSCq2vxKr45zV+FQnjWH6D2xg+E9EatLcLAdHTgtGGD80D6jM0+aOl4wJgO/f96R2aJKCQ3yvgftRhdFMOpd6oAAAAASUVORK5CYII=" role="presentation" style="pointer-events: none;" width="16" height="16"></div></div> <div class="toggle-thumb"></div></div> <input type="checkbox" aria-label="Switch between Dark and Default theme" class="toggler-screen-reader-only"></div></div>
</div>
<div class="Main">
<div class="Content" id="content">
<div class="btn-group pull-right">
<button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span>Code</span> <span class="caret"></span></button>
<ul class="dropdown-menu" style="min-width: 50px;">
<li><a id="rmd-show-all-code" href="#">Show All Code</a></li>
<li><a id="rmd-hide-all-code" href="#">Hide All Code</a></li>
</ul>
</div>
<h1 class="title">Git and GitHub from the Terminal & RStudio:
An Introduction</h1>
<p class="authors">
<span class="glyphicon glyphicon-user"></span> Valentin Lucet
</p>
<!-- Don't indent these lines or it will mess pre blocks indentation -->
<div class="page-content has-page-title">
<p><img align="right" width="300" height="100" src="https://git-scm.com/images/logos/2color-lightbg@2x.png"></p>
<p>By Valentin Lucet (<a href="https://vlucet.github.io/">Website</a>,
<a href="https://github.com/vlucet">GitHub</a>).<br /> Last updated: 03
December, 2023.</p>
<p><em>The following workshop is inspired from the following
resources:</em></p>
<ul>
<li><a href="https://happygitwithr.com/"
class="uri">https://happygitwithr.com/</a><br />
</li>
<li><a
href="https://blog.developer.atlassian.com/a-better-pull-request/"
class="uri">https://blog.developer.atlassian.com/a-better-pull-request/</a><br />
</li>
<li><a
href="https://www.nobledesktop.com/blog/what-is-git-and-why-should-you-use-it"
class="uri">https://www.nobledesktop.com/blog/what-is-git-and-why-should-you-use-it</a></li>
</ul>
<p><em>We will also use <a
href="https://onlywei.GitHub.io/explain-git-with-d3/">this amazing
website</a> as a visual aid.</em></p>
<hr />
<div id="preparation" class="section level3">
<h3>Preparation</h3>
<p><strong>(1) Complete section 1 of the happywithgithr workshop
(“Installation”)</strong></p>
<ol style="list-style-type: decimal">
<li><a href="https://happygitwithr.com/github-acct.html">Register on
GitHub</a></li>
<li><a href="https://happygitwithr.com/install-r-rstudio.html">Install
or update Rstudio</a></li>
<li><a href="https://happygitwithr.com/install-git.html">Install &
Configure git</a></li>
<li><a href="https://happygitwithr.com/hello-git.html">Introduce
yourself to git</a></li>
</ol>
<p><strong>(2) Set up HTTPS or SSH protocols by completing part of
section 2 of the happywithgithr workshop (“Connect Git, GitHub,
RStudio”)</strong> <strong>If you are having issues with this step,
please reach out to me a prior to the training so that I can help
you.</strong></p>
<p>This step is important because it allows you to securely connect you
to GitHub every time you want to use it from your computer.</p>
<ol style="list-style-type: decimal">
<li>Read the <a
href="https://happygitwithr.com/connect-intro.html">section’s
intro</a></li>
<li>Read the <a
href="https://happygitwithr.com/https-pat.html#https-vs-ssh">comparison
between https and ssh</a></li>
<li>Set up <a href="https://happygitwithr.com/https-pat.html">https</a>
OR <a href="https://happygitwithr.com/ssh-keys.html">ssh</a></li>
</ol>
<p><strong>(3) <a
href="https://speakerdeck.com/alicebartlett/git-for-humans">Learn
<strong>5 key things</strong> about Git</a></strong> Thanks to Alice
Bartlett from the Financial times for this great intro to Git.</p>
<p><strong>Note: This tutorial gives you the choice to either complete
it at the terminal or in RStudio.</strong></p>
<p>There is value in being able to do all of this in the command line,
because it allows to build a mental model of how git works, which is
extremely useful if you do not have access to an UI (this is the case
when you are working on a supercomputer for instance). <strong>A note on
the Git/Github/Rstudio nexus:</strong> Rstudio has integrated git in its
interface. This can turn out be a lovely thing, but sometimes leads to
problems. I advise you to <a
href="https://happygitwithr.com/troubleshooting.html">bookmark this
troubleshooting guide for later just in case.</a>).</p>
<hr />
</div>
<div id="exercise-1-once-upon-a-commit" class="section level2">
<h2>Exercise 1: Once upon a commit…</h2>
<p>Let’s start by creating a new directory, this will be our project
directory. Open the terminal on your computer if you are on Mac or Linux
(or the git console if you are on Windows) and use the
<code>mkdir</code> command like below (stands for “make directory”). The
<code>cd</code> command, for “change directory”, allows us to move into
this new directory.</p>
<div id="a-note-on-project-oriented-workflows" class="section level3">
<h3>A note on Project-oriented workflows</h3>
<p>Git is an example of a tool that requires a project oriented
workflow. Git needs to know that files to watch for, and it cannot watch
your whole computer (well, in a way, it could, but we’re not kernel
maintainers). So git needs to be contained to a folder at a time (a
project at a time). This suggests working in such a way that all you
need for your project be placed and organized in a project folder. The
good news is that RStudio is designed to work like this. To read more
about project-oriented workflows, I highly recommend this <a
href="https://www.tidyverse.org/blog/2017/12/workflow-vs-script/">little
post</a> by Jenny Bryan on the tidyverse blog.</p>
</div>
<div id="at-the-terminal" class="section level3">
<h3>At the terminal</h3>
<pre class="bash"><code>cd ~ # Go to your home directory
mkdir gitWorkshop # Creates a new directory called gitWorkshop in your home directory
cd gitWorkshop # Moves to inside the new directory</code></pre>
<p>Now that you have a fresh directory, we need to make it a git
repository, aka a <strong>repo</strong> (i.e. a directory in which git
is activated and is tracking files). To make this work you need to
initialize git. It’s simple:</p>
<pre class="bash"><code>git init # This initialize git in your directory</code></pre>
<pre><code>Initialized empty Git repository in /home/vlucet/gitWorkshop/.git/</code></pre>
</div>
<div id="in-rstudio" class="section level3">
<h3>In RStudio</h3>
<p>To use git in Rstudio, you need to create a new <a
href="https://support.rstudio.com/hc/en-us/articles/200526207-Using-Projects">Project</a>.
Let’s start by creating our project directory.</p>
<ul>
<li>Open RStudio, in the top right corner create a new project</li>
</ul>
<center>
<img src="images/Step_1.png" />
</center>
<ul>
<li>Select <strong>New Directory</strong> Note that <strong>Version
Control</strong> is reserved for when you already created a repo on
GitHub. We will come back to this later.</li>
</ul>
<center>
<img src="images/Step_2.png" style="width:50.0%" />
</center>
<ul>
<li>Select <strong>New Project</strong></li>
</ul>
<center>
<img src="images/Step_3.png" style="width:50.0%" />
</center>
<ul>
<li>Choose a name for your repo and a location. <strong>Make sure that
<em>create a git repository</em> is checked</strong></li>
</ul>
<center>
<img src="images/Step_4.png" style="width:50.0%" />
</center>
<ul>
<li>You can now look under the <em>git tab</em>, you should see
this:</li>
</ul>
<center>
<p><img src="images/final.png" /></p>
</center>
<p><strong>Note: we will come back to what the <em>.gitignore</em> file
is later!</strong></p>
<hr />
<blockquote>
<p><strong>Let’s now create a new file, the first file we want to keep
track of in this project</strong></p>
</blockquote>
</div>
<div id="at-the-terminal-1" class="section level3">
<h3>At the terminal</h3>
<p>We create a file using the <code>touch</code> command:</p>
<pre class="bash"><code>touch script_1.R # Creates the file</code></pre>
</div>
<div id="in-rstudio-1" class="section level3">
<h3>In Rstudio</h3>
<p>Create a new file: go to the menu <em>File => New file => R
Script</em>. Make sure to save it with the name <em>script_1.R</em>.</p>
<hr />
<blockquote>
<p><strong>The repo is created and you have created a file, can git see
the new file?</strong></p>
</blockquote>
</div>
<div id="at-the-terminal-2" class="section level3">
<h3>At the terminal</h3>
<p>With the <code>ls</code> command, which lists everything in your
directory, you can see the file you have created. By editing the empty
file and saving it, we created a change in this file.</p>
<p>At any time, git lets you know if you have a untracked file, thanks
to the <code>git status</code> command.</p>
<pre class="bash"><code>ls # This lists the files in the directory. You should see your file listed!
git status # Shows the current status of your repo with regards to git</code></pre>
<pre><code>On branch main
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
script_1.R
nothing added to commit but untracked files present (use "git add" to track)</code></pre>
</div>
<div id="in-rstudio-2" class="section level3">
<h3>In Rstudio</h3>
<p>No need for the <code>status</code> command in RStudio, the
<em>Git</em> tab shows you in real time the status of your files:</p>
<ul>
<li>Files that are <strong>untracked</strong> are represented by a
<strong>yellow question mark</strong>.</li>
<li>Files that have been <strong>added</strong> (see next section) are
represented by a <strong>green A</strong></li>
<li>Files that have been <strong>tracked and modified</strong> are
represented by a <strong>blue M</strong>.</li>
<li>Files that are <em>tracked but not modified</em> do not show.</li>
<li>Files that have been <strong>deleted</strong> are shown with a
<strong>red D</strong>.</li>
</ul>
<hr />
<blockquote>
<p><strong>By default, Git does not track anything. We need to tell it
to do so. Let’s do that now!</strong></p>
</blockquote>
</div>
<div id="at-the-terminal-3" class="section level3">
<h3>At the terminal</h3>
<p>From the terminal, we can use the <code>git add</code> command. This
tells git which file you care about and want to start tracking. This is
called <strong>Staging the file</strong>.</p>
<pre class="bash"><code>git add script_1.R
git status # Status now shows, in green, which changes have to be committed</code></pre>
<pre><code>On branch main
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: script_1.R</code></pre>
</div>
<div id="in-rstudio-3" class="section level3">
<h3>In Rstudio</h3>
<p>In RStudio, this is as simple as “checking off” the file in the Git
tab. This is called <strong>Staging the file</strong>.</p>
<center>
<img src="images/checked.png" />
</center>
<p>While you are at it, make sure to also check the
<code>.gitignore file.</code> <strong>What is a gitignore?</strong> A
gitignore is a file that lists the file you never want git to track. It
can match certain file names (for instance, <code>.csv</code> or
<code>.tif</code> files). This can be useful in case you need to make
sure certain files (like data files or large files), do not get
added.</p>
<hr />
<blockquote>
<p><strong>Let’s now make sure this new file is registered by git: this
is called a <em>commit</em></strong></p>
</blockquote>
</div>
<div id="at-the-terminal-4" class="section level3">
<h3>At the terminal</h3>
<p>We have staged the file. Let’s now take a snapshot of this file with
the <code>git commit</code> command. It is important to add a useful
message to your commit, a bit like a journal entry, so that you can
remember what you committed.</p>
<pre class="bash"><code>git commit -m "First commit - adding script1" # the -m flag adds a message to a commit</code></pre>
<pre><code>[main (root-commit) 03a1fe9] First commit - adding script1
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 script_1.R</code></pre>
<p>Another useful command: git <code>log</code> shows you the recent
commit history.</p>
<pre class="bash"><code>git log # Git log shows you the history</code></pre>
<pre><code>commit 03a1fe9489631db018d4ae6d39560ce2e5e00ead (HEAD -> main)
Author: VLucet <valentin.lucet@gmail.com>
Date: Wed Apr 8 18:19:53 2020 -0400
First commit - adding script1</code></pre>
</div>
<div id="in-rstudio-4" class="section level3">
<h3>In Rstudio</h3>
<p>In Rstudio, committing is a few clicks away.</p>
<ul>
<li>Click on <code>commit</code> on the top of the file list. This
window should appear:</li>
</ul>
<center>
<img src="images/commit.png" style="width:75.0%" />
</center>
<ul>
<li>Before committing anything you need to add a commit message. It is
important to add a useful message to your commit, a bit like a journal
entry, so that you can remember what you committed.</li>
</ul>
<center>
<img src="images/message.png" style="width:50.0%" />
</center>
<ul>
<li>Click on commit in order to commit the changes!</li>
</ul>
<hr />
<blockquote>
<p><strong>Let’s now make some changes to this file and commit
them</strong></p>
</blockquote>
</div>
<div id="at-the-terminal-5" class="section level3">
<h3>At the terminal</h3>
<p>The code below opens the <strong>nano</strong> editor. <a
href="https://www.nano-editor.org/"><code>Nano</code></a> is a simple
command line file editor. Once the file is opened, you will see the
(empty) content of the file.</p>
<pre class="bash"><code>nano script_1.R # This opens the nano Text editor. </code></pre>
<p>Type in what you want. You can then close the editor with
<code>ctrl+X</code>. Make sure to type <code>y</code> for yes and press
<code>enter</code> to save the file. If you do not want to use the
terminal for this (or do not have nano), you can just open the file in a
file editor.</p>
<p>We now need to stage (<code>git add</code>) and commit
(<code>git commit</code>)</p>
<pre class="bash"><code>git add -A # This adds ALL (hence the -A) the changes you made to the git index.
# Your changes are now registered
# You could also just do git add script_1.R if you wanted to
git status # Status now shows, in green, which changes have to be committed</code></pre>
<pre><code>On branch main
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: script_1.R</code></pre>
<p>Now let’s commit:</p>
<pre class="bash"><code>git commit -m "First commit - adding script1" # the -m flag adds a message to a commit</code></pre>
<pre><code>[main (root-commit) e07b863] First commit - adding script1
1 file changed, 1 insertion(+)
create mode 100644 script_1.R</code></pre>
</div>
<div id="in-rstudio-5" class="section level3">
<h3>In Rstudio</h3>
<ul>
<li>Open your file in the editor, and add some modifications. Make sure
to save it. When you open the git tab, you should see the
following:</li>
</ul>
<center>
<img src="images/mod_step1.png" />
</center>
<ul>
<li>Now, <em>Stage the file</em> by checking it.</li>
</ul>
<center>
<img src="images/mod_step2.png" />
</center>
<ul>
<li>Then, make sure you commit once again.</li>
</ul>
<center>
<img src="images/mod_step3.png" />
</center>
<p><strong>Note</strong>: take a look at the <strong>history</strong>
tab in the commit window.</p>
<hr />
<p>Note that once you have staged a file, you could do more changes, and
you would need to re-run <code>git add</code> to add them to the index.
Those changes not yet fully registered by git, they are like a draft,
not until you commit. When you want to take a snapshot of a file, it
means you are ready to commit that change to the index.</p>
<p>This image summarizes what we have learned so far. Each change in the
repository (adding a file, modifying a file, etc…) needs to be staged
before it is committed.</p>
<center>
<img src="https://git-scm.com/images/about/index1@2x.png"
style="width:65.0%" />
</center>
<hr />
</div>
</div>
<div id="exercise-2-all-roads-lead-to-github-how-to-add-a-remote"
class="section level2">
<h2>Exercise 2: All roads lead to GitHub, how to add a remote</h2>
<p>After having created a repo on your local machine (and provided that
you have configured git on your computer), you will be able to link your
repo to GitHub, an online hub for repositories.</p>
<p>“Linking” can mean multiple things depending on where you start
things. If you start on your computer, we call this
<strong>pushing</strong> your local repo to the remote. After pushing, a
copy of your repo will live on the GitHub servers and will remain linked
to the original copy. The GitHub copy is called a
<strong>remote</strong>.</p>
<hr />
<blockquote>
<p><strong>We first need to create the remote repository on <a
href="GitHub.com">GitHub</a></strong></p>
</blockquote>
<p>The first thing to do is to create the remote:</p>
<ul>
<li>Log in, then click on the green folder.</li>
</ul>
<center>
<img src="images/green_github.png" />
</center>
<ul>
<li>Give a name to your repo. It’s good practice to the use the same
name than your local git repo (it’s also easier to remember that way!).
<strong>Do not</strong> add a <code>README.md</code> or
<code>.gitignore</code>. The repo needs to be
<strong>empty</strong>.</li>
</ul>
<center>
<img src="images/create_repo.png" style="width:75.0%" />
</center>
<p>The next thing is to tell your local git that you have created a new
remote. You will name this the <strong>origin</strong> remote. Why
<strong>origin</strong>? Because from the point of view of project
development, you want this online repo to be the origin of all future
work, and you want the online version to save all that matters!</p>
<hr />
<blockquote>
<p><strong>Let’s now link your local repo with the GitHub
“remote”</strong></p>
</blockquote>
<div id="at-the-terminal-6" class="section level3">
<h3>At the terminal</h3>
<ul>
<li>Tell git the address of your remote</li>
</ul>
<pre class="bash"><code>git remote add origin https:... # Add here the URL of your git repo,
# for instance https://GitHub.com/VLucet/gitWorkshoptest</code></pre>
<ul>
<li>You now need to upload your repo to the remote, i.e. to
<strong>push</strong> your commits. The first time you push, you have to
tell git that the remote is an <strong>upstream branch</strong> (more on
that later).</li>
</ul>
<pre class="bash"><code> git push --set-upstream origin main # This pushes and sets the remote as "upstream"</code></pre>
<pre><code>Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 263 bytes | 263.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/VLucet/gitWorkshop
* [new branch] main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.</code></pre>
<pre class="bash"><code> git push # If you try to push again,
# it will tell you that everything is up to date!</code></pre>
<pre><code>Everything up-to-date</code></pre>
<p>There you go! you now have a copy of your repo on GitHub. Well
done!</p>
</div>
<div id="in-rstudio-6" class="section level3">
<h3>In Rstudio</h3>
<ul>
<li>In Rstudio you have to click to the <strong>New Branch</strong>
button in the git pane, in the top right corner of the pane:</li>
</ul>
<center>
<img src="images/new_branch_icon.png" style="width:50.0%" />
</center>
<ul>
<li>The dialogue window should open, click on <strong>add
remote</strong></li>
</ul>
<center>
<img src="images/dialogue_1.png" style="width:50.0%" />
</center>
<ul>
<li>Put <strong>origin</strong> as the remote name. Why
<strong>origin</strong>? Because from the point of view of project
development, you want this online repo to be the origin of all future
work, and you want the online version to save all that matters! Put the
also address of your repo (for instance for me it is
<code>for instance https://github.com/VLucet/gitWorkshoptest</code>)</li>
</ul>
<center>
<img src="images/dialogue_2.png" style="width:50.0%" />
</center>
<ul>
<li>Back to the previous dialogue box, write <strong>main</strong> as
the main branch and make sure to tick the box <strong>sync branch with
remote</strong>.</li>
</ul>
<center>
<img src="images/dialogue_3.png" style="width:50.0%" />
</center>
<ul>
<li>You can now push your commits by clicking on the
<strong>push</strong> button. You can go to to your repo to see the
changes.</li>
</ul>
<center>
<img src="images/push.png" style="width:50.0%" />
</center>
<p>There you go! you now have a copy of your repo on GitHub. Well done!
From now on you can continue to <strong>add</strong>,
<strong>commit</strong> and <strong>push</strong> your commits.</p>
<!-- **Note:** it is also possible to start the repo on GitHub and download a **clone**. It is the opposite operation (see exercise 4). -->
<hr />
</div>
</div>
<div
id="exercise-3-teamwork-makes-the-dream-work-or-collabaring-with-git"
class="section level2">
<h2>Exercise 3: Teamwork makes the dream work, or collabaring with
git</h2>
<p>Git is made for collaboration. In one image, this can be summarized
like this:</p>
<p><img
src="https://www.nobledesktop.com/image/blog/git-branches-merge.png" /></p>
<p>Form teams of 3 and designate a <strong>Repo Owner</strong> for this
exercise. For this exercise and the next one, we will see the other way
to start a repo, by starting it on Github and then
<strong>cloning</strong> it onto your computer.</p>
<ul>
<li>Repo Owner <strong>only</strong>, head over to GitHub to create a
new online repository</li>
</ul>
<center>
<img src="images/green_github.png" />
</center>
<ul>
<li>This time, make sure to initiate this repository with a
<strong>ReadMe</strong> file. A <code>ReadMe</code> file is an important
file for a repo, as it is there to describe the purpose of the repo and
contains important metadata on that repo.</li>
</ul>
<center>
<img src="images/Add_readme.png" />
</center>
<ul>
<li>Modify the ReadMe directly in GitHub by clicking on the small pencil
in the corner. You can edit most files directly in GitHub.</li>
</ul>
<center>
<img src="images/edit_readme.png" />
</center>
<ul>
<li>Type some changes</li>
</ul>
<center>
<img src="images/Type_in.png" />
</center>
<ul>
<li>Then, scroll down to commit your changes</li>
</ul>
<center>
<img src="images/Commit_readme.png" />
</center>
<hr />
<blockquote>
<p><strong>Let’s now invite people to collaborate on your
repo</strong></p>
</blockquote>
<ul>
<li>To do so, click on <strong>Settings</strong> then <strong>Manage
access</strong> and <strong>Invite collaborators</strong></li>
</ul>
<center>
<img src="images/settings.png" />
</center>
<ul>
<li>Use the username of your group members to invite them to
collaborate</li>
</ul>
<center>
<img src="images/invite.png" />
</center>
<hr />
<blockquote>
<p><strong>We have the repo set up for collaboration, let’s now “clone”
the repo</strong></p>
</blockquote>
<p>Cloning means “pulling” the repo from the remote, to make a copy on
your computer. It is the mirror action of pushing the repo you created
locally earlier.</p>
<div id="at-the-terminal-7" class="section level3">
<h3>At the terminal</h3>
<p>Cloning from the command line is very simple:</p>
<pre class="bash"><code>cd ~ # Navigate to your home folder again
git clone *URL* # The URL of the repo created by the repo owner</code></pre>
<p>Well done, you have now set up a team and you are now technically
working on the same repo.</p>
</div>
<div id="in-rstudio-7" class="section level3">
<h3>In Rstudio</h3>
<p>You can clone a GitHub repo from Rstudio:</p>
<ul>
<li>Open RStudio, in the top right corner create a new project</li>
</ul>
<center>
<img src="images/Step_1.png" />
</center>
<ul>
<li>Select <strong>Version Control</strong>, which is is reserved for
when you already created a repo on GitHub.</li>
</ul>
<center>
<img src="images/Step_2.png" style="width:50.0%" />
</center>
<ul>
<li>Select <strong>Git</strong>. Subversion is listed here as another
version control software supported by Rstudio.</li>
</ul>
<center>
<img src="images/select_git.png" style="width:50.0%" />
</center>
<ul>
<li>Fill the different fields as such: for the “Repository URL”, paste
the URL of the repo (of the type ‘<a
href="https://GitHub.com/VLucet/GitWorkshop.git"
class="uri">https://GitHub.com/VLucet/GitWorkshop.git</a>’), which
should update the field “Project directory name”. Finally, select where
on your computer you would like to clone the repo (the Home directory or
your Documents directory for instance).</li>
</ul>
<center>
<img src="images/new_repo_vc.png" style="width:50.0%" />
</center>
<hr />
</div>
</div>
<div id="exercise-4-do-the-push-and-pull-or-the-git-workflow"
class="section level2">
<h2>Exercise 4: (Do The) Push and Pull, or the git workflow</h2>
<p>In this next exercise, we are going to use the repo you cloned at the
previous exercise. We are now going to do the exercise of pushing and
pulling to update the GitHub repo with changes we make locally.</p>
<div id="at-the-terminal-8" class="section level3">
<h3>At the terminal</h3>
<p>The first step is to make sure you are up to date with the version of
the repo that is on GitHub. Navigate to the cloned repo an use the
<code>fetch</code> command.</p>
<pre class="bash"><code>git fetch # Fetch compares your local version with the remote version but does not apply the new changes (if there are any)</code></pre>
<p>Everything should be up to date, so all good.</p>
</div>
<div id="in-rstudio-8" class="section level3">
<h3>In Rstudio</h3>
<ul>
<li>In Rstudio, the first step is to create an Rstudio project within
the folder that you cloned from GitHub. As a reminder, this is the only
way to use git in the Rstudio context To do so, navigate to the R box in
the top right corner and click on “New Project”</li>
</ul>
<center>
<img src="images/new_project.png" />
</center>
<ul>
<li>Select “Existing directory”, we will choose the directory you cloned
from GitHub.</li>
</ul>
<center>
<img src="images/existing_directory.png" />
</center>
<ul>
<li>Browse for your directory (it should be in your home folder) and
create the new project.</li>
</ul>
<center>
<img src="images/create_project.png" />
</center>
<hr />
<blockquote>
<p><strong>Let’s now learn how to makes changes in this repo and sync
them with GitHub</strong></p>
</blockquote>
</div>
<div id="at-the-terminal-9" class="section level3">
<h3>At the terminal</h3>
<p>The next step is for one of the team members (other than the repo
owner) to make a change. Make a change to the ReadMe file for
instance.</p>
<pre class="bash"><code>nano README.md # Reminder: nano is the console editor</code></pre>
<p>Then, add, commit and push those changes:</p>
<pre class="bash"><code>git add -A # Once again, add all the changes
git commit -m "modified the README" # Always add a useful message</code></pre>
<pre><code>[main 58c8cb7] modified the README
1 file changed, 1 insertion(+), 1 deletion(-)</code></pre>
<pre class="bash"><code>git push origin main # Push it!</code></pre>
<pre><code>Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 313 bytes | 313.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To github.com:VLucet/gitWorkshop.git
a992c9a..58c8cb7 main -> main</code></pre>
</div>
<div id="in-rstudio-9" class="section level3">
<h3>In Rstudio</h3>
<ul>
<li>Open the ReadMe in the editor and modify it. Save the changes. The
git pane should look something like that:</li>
</ul>
<center>
<img src="images/new_changes.png" />
</center>
<ul>
<li>As in the previous exercises, you can commit and push the new
change. You have now pushed new changes to the repo, but the rest of
your team is now behind.</li>
</ul>
<hr />
<blockquote>
<p><strong>One group member has made changes to the repo, let’s make
sure the rest of the time is up to date as well!</strong></p>
</blockquote>
</div>
<div id="at-the-terminal-10" class="section level3">
<h3>At the terminal</h3>
<p>Now, two of the team members are not in sync with the changes. These
people can see it with a <code>fetch</code>. Below I cannot show the
outputs but you should be a little more familiar with these by now.</p>
<pre class="bash"><code>git fetch # This will download the changes pushed by your team member
git status # Always good to run status once in a while. Here it will tell you that you are 1 commit behind! </code></pre>
<p>You are 1 commit behind! To remedy to this, it is as simple as
<strong>pulling</strong> the changes in your local repo.</p>
<pre class="bash"><code>git pull origin main # Nice! Git will print a nice summary with green + and red -. How cute. </code></pre>
<p>Well done! You now know how to <strong>push</strong> and
<strong>pull</strong>, <strong>fetch</strong> and
<strong>status</strong> your way around a shared repo. You’re the
best.</p>
</div>
<div id="in-rstudio-10" class="section level3">
<h3>In Rstudio</h3>
<ul>
<li>In order to bring yourself back in sync with the changes pushed by
your teammate, you just need to pull those changes by clicking on the
blue pull arrow in the git pane.</li>
</ul>
<center>
<img src="images/pull_arrow.png" />
</center>
<p>Well done! You now know how to <strong>push</strong> and
<strong>pull</strong>, <strong>fetch</strong> and
<strong>status</strong> your way around a shared repo. You’re the
best.</p>
<hr />
<blockquote>
<p><strong>What if two people commit changes at the same line one after
the other? Its a conflict (see next exercise)</strong></p>
</blockquote>
<hr />
</div>
</div>
<div id="exercise-5-git-of-war-or-conflicts-and-how-to-resolve-them"
class="section level2">
<h2>Exercise 5 Git of war, or conflicts and how to resolve them</h2>
<p>Now, let’s do this again but a little differently. One person in the
group to not have edited the <code>README</code> yet should do it now on
their machine. Please add and commit but <strong>do not push your