-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset-up.html
820 lines (701 loc) · 29.6 KB
/
set-up.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<title>Set-up</title>
<script src="site_libs/header-attrs-2.7/header-attrs.js"></script>
<script src="site_libs/jquery-1.11.3/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="site_libs/bootstrap-3.3.5/css/readable.min.css" rel="stylesheet" />
<script src="site_libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/respond.min.js"></script>
<style>h1 {font-size: 34px;}
h1.title {font-size: 38px;}
h2 {font-size: 30px;}
h3 {font-size: 24px;}
h4 {font-size: 18px;}
h5 {font-size: 16px;}
h6 {font-size: 12px;}
code {color: inherit; background-color: rgba(0, 0, 0, 0.04);}
pre:not([class]) { background-color: white }</style>
<script src="site_libs/jqueryui-1.11.4/jquery-ui.min.js"></script>
<link href="site_libs/tocify-1.9.1/jquery.tocify.css" rel="stylesheet" />
<script src="site_libs/tocify-1.9.1/jquery.tocify.js"></script>
<script src="site_libs/navigation-1.1/tabsets.js"></script>
<link href="site_libs/highlightjs-9.12.0/textmate.css" rel="stylesheet" />
<script src="site_libs/highlightjs-9.12.0/highlight.js"></script>
<link href="site_libs/font-awesome-5.1.0/css/all.css" rel="stylesheet" />
<link href="site_libs/font-awesome-5.1.0/css/v4-shims.css" rel="stylesheet" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
</style>
<style type="text/css">code{white-space: pre;}</style>
<script type="text/javascript">
if (window.hljs) {
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
if (document.readyState && document.readyState === "complete") {
window.setTimeout(function() { hljs.initHighlighting(); }, 0);
}
}
</script>
<link rel="stylesheet" href="styles.css" type="text/css" />
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
img {
max-width:100%;
}
.tabbed-pane {
padding-top: 12px;
}
.html-widget {
margin-bottom: 20px;
}
button.code-folding-btn:focus {
outline: none;
}
summary {
display: list-item;
}
pre code {
padding: 0;
}
</style>
<style type="text/css">
.dropdown-submenu {
position: relative;
}
.dropdown-submenu>.dropdown-menu {
top: 0;
left: 100%;
margin-top: -6px;
margin-left: -1px;
border-radius: 0 6px 6px 6px;
}
.dropdown-submenu:hover>.dropdown-menu {
display: block;
}
.dropdown-submenu>a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 5px 0 5px 5px;
border-left-color: #cccccc;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu:hover>a:after {
border-left-color: #adb5bd;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left>.dropdown-menu {
left: -100%;
margin-left: 10px;
border-radius: 6px 0 6px 6px;
}
</style>
<script type="text/javascript">
// manage active state of menu based on current page
$(document).ready(function () {
// active menu anchor
href = window.location.pathname
href = href.substr(href.lastIndexOf('/') + 1)
if (href === "")
href = "index.html";
var menuAnchor = $('a[href="' + href + '"]');
// mark it active
menuAnchor.tab('show');
// if it's got a parent navbar menu mark it active as well
menuAnchor.closest('li.dropdown').addClass('active');
// Navbar adjustments
var navHeight = $(".navbar").first().height() + 15;
var style = document.createElement('style');
var pt = "padding-top: " + navHeight + "px; ";
var mt = "margin-top: -" + navHeight + "px; ";
var css = "";
// offset scroll position for anchor links (for fixed navbar)
for (var i = 1; i <= 6; i++) {
css += ".section h" + i + "{ " + pt + mt + "}\n";
}
style.innerHTML = "body {" + pt + "padding-bottom: 40px; }\n" + css;
document.head.appendChild(style);
});
</script>
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
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 > 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;
}
</style>
<!-- code folding -->
<style type="text/css">
#TOC {
margin: 25px 0px 20px 0px;
}
@media (max-width: 768px) {
#TOC {
position: relative;
width: 100%;
}
}
@media print {
.toc-content {
/* see https://github.com/w3c/csswg-drafts/issues/4434 */
float: right;
}
}
.toc-content {
padding-left: 30px;
padding-right: 40px;
}
div.main-container {
max-width: 1200px;
}
div.tocify {
width: 20%;
max-width: 260px;
max-height: 85%;
}
@media (min-width: 768px) and (max-width: 991px) {
div.tocify {
width: 25%;
}
}
@media (max-width: 767px) {
div.tocify {
width: 100%;
max-width: none;
}
}
.tocify ul, .tocify li {
line-height: 20px;
}
.tocify-subheader .tocify-item {
font-size: 0.90em;
}
.tocify .list-group-item {
border-radius: 0px;
}
.tocify-subheader {
display: inline;
}
.tocify-subheader .tocify-item {
font-size: 0.95em;
}
</style>
</head>
<body>
<div class="container-fluid main-container">
<!-- setup 3col/9col grid for toc_float and main content -->
<div class="row">
<div class="col-sm-12 col-md-4 col-lg-3">
<div id="TOC" class="tocify">
</div>
</div>
<div class="toc-content col-sm-12 col-md-8 col-lg-9">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">RWorkflow</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="set-up.html">
<span class="fas fa-clone"></span>
Set-up
</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<span class="fab fa-git"></span>
Git
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="intro-git.html">
<span class="fab fa-github"></span>
Intro to Git + GitHub
</a>
</li>
<li>
<a href="more-git.html">
<span class="fab fa-github-alt"></span>
More Git + GitHub
</a>
</li>
<li>
<a href="gitlab-to-github.html">
<span class="fas fa-truck-moving"></span>
GitLab to GitHub
</a>
</li>
<li>
<a href="websites.html">
<span class="fab fa-chrome"></span>
Websites with GitHub
</a>
</li>
<li>
<a href="jekyll.html">
<span class="fas fa-sitemap"></span>
Dynamic Websites with Jekyll and GitHub
</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<span class="fas fa-file"></span>
RMarkdown
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="week3-RMarkdown.html">
<span class="fas fa-file"></span>
R Markdown for Reports
</a>
</li>
<li>
<a href="bookdown.html">
<span class="fas fa-book"></span>
Bookdown
</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<span class="fas fa-archive"></span>
R Packages
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="week4-packages.html">
<span class="fas fa-archive"></span>
R Packaging with RStudio
</a>
</li>
<li>
<a href="week5-roxygen.html">
<span class="fas fa-question-circle"></span>
Roxygen documentation
</a>
</li>
<li>
<a href="week6-more-packages.html">
<span class="fas fa-folder"></span>
More package stuff
</a>
</li>
<li>
<a href="shiny.html">
<span class="fas fa-gamepad"></span>
Shiny GUIs
</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<span class="fas fa-broom"></span>
Tidyverse
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="week8-ggplot2.html">
<span class="fas fa-image"></span>
ggplot2
</a>
</li>
<li>
<a href="week9-data-wrangling.html">
<span class="fas fa-broom"></span>
tidyr
</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
More
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="links.html">Tutorials</a>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/RVerse-Tutorials/RWorkflow">
<span class="fab fa-github"></span>
Repo
</a>
</li>
<li>
<a href="search.html">Search</a>
</li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
<div id="header">
<h1 class="title toc-ignore">Set-up</h1>
</div>
<p>If you want to follow along with the presentations, you will need R, RStudio, a GitHub or GitLab account, and GitHub Desktop or Git+GitHub Desktop. Note GitHub Desktop works with both GitHub and GitLab and I will illustrate both.</p>
<p>Summary of the set-up steps. You can also consult this <a href="https://happygitwithr.com/">great online reference</a>.</p>
<div id="git-from-rstudio" class="section level1">
<h1>Git from RStudio</h1>
<p>For the class, I am showing Git within RStudio, but it can be a real headache to get working for beginners. The following set-up is most likely to work.</p>
<ol style="list-style-type: decimal">
<li>Get a GitHub or GitLab account</li>
<li>Install Git for your operating system</li>
<li>Install R (if needed)</li>
<li>Install RStudio (if needed)</li>
<li>Tell RStudio where git.exe is located</li>
<li>Tell Git how to store and get your GitHub/GitLab username and password</li>
<li>Do your first Push from the shell to store your username and password.</li>
</ol>
</div>
<div id="git-from-github-desktop" class="section level1">
<h1>Git from GitHub Desktop</h1>
<p>I normally work with Git from GitHub Desktop only. It tends not to have the authentication headaches that Git in RStudio has. However, for the class I am going to work with Git from RStudio but I will also show GitHub Desktop. GitHub Desktop doesn’t have the authentication headaches that Git in RStudio has.</p>
<ol style="list-style-type: decimal">
<li>Get a GitHub or GitLab account</li>
<li><del>Install Git for your operating system</del> Installing GitHub Desktop will also install Git now.</li>
<li>Install GitHub Desktop</li>
<li>Install R (if needed)</li>
<li>Install RStudio (if needed)</li>
</ol>
<p>Next steps depend if you are a GitHub user or GitLab user:</p>
<p>GitHub: Login to GitHub from GitHub Desktop</p>
<p>GitLab:</p>
<ol style="list-style-type: decimal">
<li>Create a PUBLIC repo on GitLab.</li>
<li>Copy its URL.</li>
<li>Open GitHub Desktop. Click File > Clone Repository > URL. Then paste in the URL of the GitLab repo. Pick a directory to save the repo in.</li>
<li>Open the new repo in RStudio and make a change to a file. Save.</li>
<li>Go back to GitHub Desktop. Commit the change.</li>
<li>Push. A window will popup asking for your username and password.</li>
<li>You’re done. Next time it won’t need to ask.</li>
</ol>
<p>To use both, do both sets of steps above.</p>
</div>
<div id="details" class="section level1">
<h1>Details</h1>
<div id="github-and-gitlab" class="section level2">
<h2>GitHub and GitLab</h2>
<div id="nwfsc-staff" class="section level3">
<h3>NWFSC staff</h3>
<p><strong>GitHub</strong> If you are using GitHub in a work capacity, as opposed to purely non-work or school, then the repositories you post should be intended for public use (as opposed to just a personal repo). GitHub is officially allowed for a platform for release of products and provides a nice platform for that. I’ll show a few examples. There is paperwork to fill out <a href="https://docs.google.com/document/d/1KFajoHazgpm55c1wlGeaaq0gRKVoQviAK0yurOQNr8c/view">info</a> and <a href="https://drive.google.com/file/d/0B6s8nwvlch0hZ0VWR01rVmtuUGs/view">checklist</a>. Key point is that GitHub is not NOAA-controlled and sensitive information and data that needs to stay on government computers should not be on GitHub.</p>
<p><strong>GitLab</strong> If you want to have repositories for work that is not intended for the public or that involve data, code, or reports that cannot be on a non-NOAA computer, then you can use the NWFSC GitLab server. Contact Marcus Nedelmann at NWFSC to get an account. No paperwork needed. Note it is easy to import back and forth between GitHub and GitLab.</p>
</div>
<div id="non-noaa-participants-or-those-using-githubgitlab-purely-for-non-noaa-work" class="section level3">
<h3>Non-NOAA participants or those using GitHub/GitLab purely for non-NOAA work</h3>
<p>If you don’t already have an account on GitHub, go to <a href="https://github.com">github.com</a> and click the “sign up” link near upper right of the page. It is pretty self-explanatory. Go ahead and get a <strong>free</strong> account. The free GitHub account does not have private repositories. Everything is public and viewable. You can upgrade (for money) and get private repositories.</p>
<p><a href="gitlab.com">GitLab</a> is quite similar to GitHub as a platform but is missing some of the nice features of creating a website for your repos. You can do it but just not as integrated. But GitLab’s free account gives you unlimited private repos.</p>
</div>
</div>
<div id="git-for-your-os" class="section level2">
<h2>Git for your OS</h2>
<ul>
<li>Windows <a href="https://gitforwindows.org/" class="uri">https://gitforwindows.org/</a> <a href="https://happygitwithr.com/install-git.html#install-git-windows">Read notes here</a></li>
<li>Mac It should be installed. Open a terminal window and type, <code>git --version</code>. If it asks to install XCode, say Yes. <a href="https://happygitwithr.com/install-git.html#macos">Read notes here</a></li>
</ul>
</div>
<div id="github-desktop" class="section level2">
<h2>GitHub Desktop</h2>
<p>GitHub Desktop is a nice Git interface for basic work. Despite the name, GitHub Desktop works just as well with GitLab.</p>
<ol style="list-style-type: decimal">
<li>Go to <a href="https://desktop.github.com/">desktop.github.com</a> and install.</li>
<li>Open GitHub Desktop, go to ‘GitHub Desktop > Preferences’ menu.<br />
</li>
<li>Under ‘Accounts’, sign into your GitHub account.</li>
<li>Under ‘Git’, enter your name (or initials) and the email you used for your GitHub account.</li>
</ol>
<p>If you are using GitLab:</p>
<ol style="list-style-type: decimal">
<li>Create a PUBLIC repo on GitLab.</li>
<li>Copy its URL.</li>
<li>Open GitHub Desktop. Click File > Clone Repository > URL. Then paste in the URL of the GitLab repo. Pick a directory to save the repo in.</li>
<li>Open the new repo in RStudio and make a change to a file. Save.</li>
<li>Go back to GitHub Desktop. Commit the change.</li>
<li>Push. A window will popup asking for your username and password.</li>
<li>You’re done. Next time it won’t need to ask.</li>
</ol>
</div>
<div id="r-and-rstudio" class="section level2">
<h2>R and RStudio</h2>
<ul>
<li><p><strong>R:</strong> Make sure you have a fairly recent version of R.<br />
Go to <a href="https://cran.r-project.org/">CRAN</a> and find the download link for your computer system. Those using a NOAA computer, contact IT to help you update/install.</p></li>
<li><p><strong>RStudio:</strong> Install the latest version of RStudio. Get it from <a href="https://www.rstudio.com/products/rstudio/download">RStudio</a> and install the appropriate one for your operating system (Windows or Mac). Again contact IT to help install if you are on a NOAA computer.</p></li>
</ul>
</div>
<div id="set-up-rstudio-to-use-git" class="section level2">
<h2>Set up RStudio to use Git</h2>
<p>If you want to use Git within RStudio, do these steps. Note it is not necessary to use Git in RStudio. You can use GitHub Desktop (or any other Git GUI or the terminal command line).</p>
<ol style="list-style-type: decimal">
<li>Open RStudio</li>
<li>Go to Global Options (from the Tools menu)</li>
<li>Click Git/SVN</li>
<li>Click Enable version control interface for RStudio projects</li>
<li>You will need the location of the git executible. On my mac the value in the <code>Git executible</code> box is <code>/usr/bin/git</code>. On my PC, it is <code>C:/Program Files/Git/bin/git.exe</code>. If you install Git for Windows locally, it may be at <code>C:\Users\your.username\AppData\Local\Programs\Git\bin\git.exe</code>.</li>
</ol>
<p>Tell Git how to get your username and password for GitHub/GitLab</p>
<ol style="list-style-type: decimal">
<li>Open a terminal window.</li>
<li>Type <code>git config --get credential.helper</code></li>
<li>If you are on a PC, you should see <code>manager</code> and if on a mac, <code>osxkeychain</code></li>
<li>If not type, Mac: <code>git config --global credential.helper osxkeychain</code> Windows: <code>git config --global credential.helper manager</code></li>
</ol>
<p>There is one more step that comes up on your first push to the remote. You’ll need to do your very first Push from the Shell within RStudio so that it knows your username and password.</p>
<ol style="list-style-type: decimal">
<li>Open up your local repo in RStudio.</li>
<li>Make a change to a file and commit the change.</li>
<li>Click on the Git tab, click the cog icon and click <code>Shell...</code></li>
<li>Type <code>git push</code></li>
<li>It should ask for your GitHub or GitLab username and password.</li>
</ol>
</div>
<div id="gitlab-and-ssh-keys-and-ssl-tokens" class="section level2">
<h2>GitLab and SSH keys and SSL tokens</h2>
<p>In order to connect to GitLab, you will need to make an SSH key. GitLab will ask you for this. Note, I am not 100% sure GitLab actually needs this. If it let’s you, you can try skipping this.</p>
<p>Windows users: The txt file with the public token will be xxx.pub and Windows sees that as a MSPublisher file. Don’t double-click the file to open. Use Open With, and select a text editor.</p>
<ol style="list-style-type: decimal">
<li>Open a terminal</li>
<li>Type this <code>ssh-keygen -t ed25519 -C "gitlab"</code></li>
<li>Hit ‘return’ at each prompt (for filename and for password). Don’t enter anything.</li>
<li>Ignore what is printed out. Navigate to Users/yourname/.ssh/id_ed25519</li>
<li>Open with an editor (like Notepad or TextEdit)</li>
<li>Copy the key. It’s long and begins with ssh-ed25519.</li>
<li>Paste into the page where GitHub asks for it. Lost that place? It’s in Settings>SSH keys</li>
</ol>
</div>
</div>
<div id="help" class="section level1">
<h1>Help!</h1>
<p>Can’t get Git, GitHub/GitLab, and RStudio to connect?</p>
<p>First off, can you get GitHub Desktop to work? If so, I would say just use that for awhile. You don’t need to use Git in RStudio.</p>
<p>If you want to use Git in RStudio, read on. You can also consult this <a href="https://happygitwithr.com/">great online resource</a>.</p>
<p>There are two typical problems. 1. Git doesn’t know how to ask you for your username and password. 2. Your repo is pointing to the wrong GitHub/GitLab account. This can happen when you try to copy someone else’s account.</p>
<div id="does-rstudio-or-github-desktop-complain-about-no-ssl-tokens-when-you-try-to-push" class="section level3">
<h3>Does RStudio or GitHub Desktop complain about no SSL tokens when you try to Push?</h3>
<ol style="list-style-type: decimal">
<li>Open a terminal window.</li>
<li>Paste in this code <code>git config --global http.sslVerify false</code></li>
</ol>
</div>
<div id="does-rstudio-complain-about-needing-access-to-your-credentials" class="section level3">
<h3>Does RStudio complain about needing access to your credentials?</h3>
<ul>
<li>First, you should have a fairly recent version of RStudio because the Git integration has gotten better.</li>
<li>If you have a pop-up window, click ‘Deny’. Hopefully a terminal window pops up and asks for your GitHub or GitLab username and password.</li>
</ul>
</div>
<div id="does-rstudio-say-it-cannot-find-bash.exe" class="section level3">
<h3>Does RStudio say it cannot find bash.exe?</h3>
<p>RStudio doesn’t know where <code>git.exe</code> is. First, have you installed Git yet?</p>
<p>If you are on Windows and you have not installed Git, install <a href="https://gitforwindows.org/">Git for Windows</a>. Mac users should have it already. Mac It should be installed. Open a terminal window and type, git –version. If it asks to install XCode, say Yes.</p>
<p>Next, tell RStudio where to find <code>git.exe</code>. You need to tell it under Tools > Global Options > Git/SVN > Git executible. On my mac the value in the <code>Git executible</code> box is <code>/usr/bin/git</code>. On my PC, it is <code>C:/Program Files/Git/bin/git.exe</code> but IT installed it for me and installed for all users (so with admin). If you install Git for Windows locally (meaning you install it just for your account instead of for all users on your computer), it should be at <code>C:\Users\your.username\AppData\Local\Programs\Git\bin\git.exe</code></p>
</div>
<div id="does-rstudio-ask-for-your-username-and-password-every-time-you-try-to-push" class="section level3">
<h3>Does RStudio ask for your username and password every time you try to push?</h3>
<p>You need to do a push from the terminal to store your username/password.</p>
<ol style="list-style-type: decimal">
<li>Open up your project in RStudio and click the Git tab.</li>
<li>Click on the cog icon and click <code>Shell...</code></li>
<li>Type <code>git config --get credential.helper</code> and make sure you see <code>manager</code> (or <code>wincred</code>) if on Windows and <code>osxkeychain</code> if on Mac.</li>
<li>If not, look above for the <code>git</code> command to add those credential helpers.</li>
</ol>
</div>
<div id="when-you-try-to-push-with-rstudio-do-you-get-an-error-with-askpass" class="section level3">
<h3>When you try to push with RStudio do you get an error with <code>askpass</code>?</h3>
<p>RStudio doesn’t know how to open a terminal to ask for your username and password. You’ll need to push from the shell the first time.</p>
<p>So what’s going on is that Git (within RStudio) doesn’t know how to ask you for your GitHub username and password.</p>
<ol style="list-style-type: decimal">
<li>Open up RStudio and make sure your project is showing in the top right with the blue cube with R in it (meaning you have that RStudio project loaded).</li>
<li>Make a change to a file in your project and save.</li>
<li>Click on the Git tab in the upper right window.</li>
<li>Commit that change by clicking on the little box next to the change (in the Git window), adding a comment and clicking Commit.</li>
<li>Click on the little cog and select Shell…</li>
<li>Type <code>git config --list</code>. You should see <code>credentials.helper=manager</code> (if on Windows) or <code>credentials.helper=osxkeychain</code> (if on Mac). If not type, one of these commands. Mac: <code>git config --global credential.helper osxkeychain</code> Windows: <code>git config --global credential.helper manager</code>.</li>
<li>Now Type <code>git push</code>. You should be asked for your GitHub username and password.</li>
<li>Now make another change to a file, commit the change, and try to Push with the Green arrow.</li>
</ol>
</div>
<div id="still-no-luck-authenticating" class="section level3">
<h3>Still no luck authenticating?</h3>
<p>Git might have the wrong remote.</p>
<ol style="list-style-type: decimal">
<li>Open up your project in RStudio.</li>
<li>Click the Git tab. Then click on the cog icon and click <code>Shell...</code></li>
<li>Type <code>git remote -v</code> and see if what is listed looks correct.</li>
<li>If not, the command to set the new remote is <code>git remote set-url origin URL</code> Replace <code>URL</code> with the URL of your repository!!</li>
</ol>
<!--
## Install R packages
From the command line in R Studio
1. **devtools** package. Enter the following code at the command line (`>`).
```r
install.packages("devtools")
```
2. Install the **packages** that we are going to be need. I have created a package on GitHub that will install the packages you need.
```r
devtools::install_github("RVerse-Tutorials/RWorkflowsetup")
```
-->
</div>
<div id="week-2-installing-packages-from-githubgitlab" class="section level2">
<h2>Week 2: Installing packages from GitHub/GitLab</h2>
<p>Windows people: You will need to install <a href="https://cran.r-project.org/bin/windows/Rtools/history.html">Rtools</a>.</p>
<p>Run this code to confirm that you can install packages from GitHub:</p>
<pre class="r"><code>devtools::install_github("RVerse-Tutorials/TestPackage")</code></pre>
<p>To install from the <code>gitlab.com</code> the command is similar. <code><gitlab account></code> is a dummy. Replace with the real values.</p>
<pre class="r"><code>devtools::install_gitlab("<gitlab account>/repo name")</code></pre>
<p>To install from an internal GitLab server, like the NWFSC GitLab, use this. Note for the NWFSC GitLab, you need to be on the network since this is an internal (not public) server. Again, replace the dummy variables with the real values.</p>
<pre class="r"><code>devtools::install_gitlab("<gitlab account>/repo name", host="<url of the server>")</code></pre>
</div>
<div id="optional-packages-with-c-code" class="section level2">
<h2>(Optional) Packages with C++ code</h2>
<p>We will not be doing this, but often you will want to install packages with C++ code. To do that, you will need Rtools (Windows) or Xcode (Mac)</p>
<ul>
<li><p><strong>Rtools</strong> Windows users <a href="https://cran.r-project.org/bin/windows/Rtools/">Rtools</a> also so you can build packages with C++ code if needed. See comments here about changing path. <a href="http://stat545.com/packages01_system-prep.html#windows-system-prep">Rtools</a></p></li>
<li><p><strong>Xcode</strong> Mac users Open terminal and type the following command <code>xcode-select --install</code></p></li>
</ul>
</div>
</div>
<hr>
<div style="text-align: center">
<i class="fas fa-cubes"></i> NWFSC Math Bio Program <i class="fas fa-cubes"></i>
</div>
</div>
</div>
</div>
<script>
// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
$('tr.odd').parent('tbody').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
bootstrapStylePandocTables();
});
</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 () {
// move toc-ignore selectors from section div to header
$('div.section.toc-ignore')
.removeClass('toc-ignore')
.children('h1,h2,h3,h4,h5').addClass('toc-ignore');
// establish options
var options = {
selectors: "h1,h2",
theme: "bootstrap3",
context: '.toc-content',
hashGenerator: function (text) {
return text.replace(/[.\\/?&!#<>]/g, '').replace(/\s/g, '_');
},
ignoreSelector: ".toc-ignore",
scrollTo: 0
};
options.showAndHide = false;
options.smoothScroll = true;
// tocify
var toc = $("#TOC").tocify(options).data("toc-tocify");
});
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>