-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGitHub_Tutorial.Rmd
195 lines (149 loc) · 10.6 KB
/
GitHub_Tutorial.Rmd
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
---
title: "Getting Around GitHub"
author: "Michelle Slawinski"
date: "3/11/2022"
output:
html_document:
toc: yes
toc_float: yes
pdf_document:
toc: yes
---
asdkfhskdhf
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
echo = TRUE)
```
# Welcome
Git.. GitHub.. What are they? Why do they matter? In this tutorial we will introduce you to them and provide you with the basics! This presentation is for individuals with limited knowledge on git and graphical user interfaces, although those with a robust background are more than welcome to drop some knowledge on us! From one novice git user to another, we will walk through it together.
# Learning Objectives
1. Describe git and graphical user interfaces
1. Set up and connect git, GitHub and RStudio
1. Practice navigating how to fork, branch, commit, and request a pull on Github
# Git
## What is Git?
Have you ever tried working on a project or a specific piece of code with a colleague but could not figure out what changes they made? Or have you ever overwritten your own code and had to rewrite the chunk from the beginning?
Frustrating, right? Well, git is a version control that allows you to do better. Be a better coder, communicator and person because the time you will save can then be spent elsewhere!
## Set Up
Let's get started shall we!
First, check to see if you already have Git installed.
On Windows, look for an application called "Git Bash" and on Macs, search for an application called "Terminal." Type "git version" into the terminal. If you receive a version number, Git is installed. However, if the terminal is saying unknown command, then Git it not installed.
No Git? No problem. Navigate to [git](https://git-scm.com/) and click *Downloads.* Select the software appropriate for your system and follow the remaining installation steps.
**Windows**
1. Select **"Click here to download"** This should be the version you need however, you can look below to see additional options.
1. Allow installer to download then open.
1. "Do you want to allow this app to make changes to this device?" Yes, yes you do! You will need administrative access to your computer for this.
1. Use the defaults throughout the installation process.
**Mac**
If you have Git installed, then we will most likely just need to update it. To update git follow this [video](https://modulesunraveled.com/installing-git/updating-git-if-you-have-only-version-comes-xcode-or-command-line-developer-tools)!
Otherwise, to install git:
1. Select **"Click here to download."** This should be the version you need however, you can look below to see additional options.
1. Click on the Binary installer link and select download.
1. Once it is downloaded, open the file, locate the package, right click and select "Open."
1. Follow the prompts.
1. For help with the remaining installation process, follow this
[video](https://modulesunraveled.com/installing-git/installing-git-if-you-do-not-have-xcode-or-command-line-developer-tools-installed).
## Git Configuration Basics
When you configure git you will have options on what level you would like to make configurations.
System Level: git config --system
User Level: git config --global
Project Level: git config
Let's set up some basic git configurations for our system.
1. Username: When you set your user name using global, git will use this information for anything you do.
- git config \--global user.name "Michelle Slawinski"
1. Email: Do the same thing with your email address. This should be the email you used to set up your GitHub account. If you have not signed up for a GitHub account, do that now.
- git config \--global user.email "my_email.com"
1. Viewing git configurations: Type this command and scroll to the bottom to see the configurations you set up.
- git config \--list
For other configuration options see [here](https://git-scm.com/docs/git-config).
## Help Options
Are you stuck? Ask Git! In the terminal, type "git help" and it will return some common Git commands. If you want to learn more about a specific command such as branching, you can type "git help branch" and it will pull up a manual on branching.
![image](git help branch.PNG)
## Git Resources
* [Pro Git Book](https://git-scm.com/book/en/v2)
* [Git Reference Guides](https://git-scm.com/docs)
* [GitHub Git Guides](https://github.com/git-guides/install-git)
* ['Awesome Git' Repository](https://github.com/dictcp/awesome-git)
* [LinkedIn Learning Git Essential Training: The Basics](https://www.linkedin.com/learning-login/share?account=42166124&forceAccount=false&redirect=https%3A%2F%2Fwww.linkedin.com%2Flearning%2Fgit-essential-training-the-basics%3Ftrk%3Dshare_ent_url%26shareId%3DSxKxywffQ8iDu%252FzDfk84uw%253D%253D)
# Graphical User Interface
## What is a Graphical User Interface?
Git but better. Graphical User Interfaces (GUIs) are where you can use Git but in a more visually pleasing manner. Instead of using command lines in Git, you can use a click-based GUI. Think of it like using R/SAS versus SPSS or Jasp.
## Popular GUIs
Microsoft | Mac
---------|----------
GitHub Desktop | GitHub Desktop
GitKraken | GitKraken
Sourcetree | Sourcetree
TortoiseGit | Fork
SmartGit |
## GUI Resources
* [GUI Clients](https://git-scm.com/downloads/guis)
* [GitHub Help](https://docs.github.com/en)
* [GitHub Training and Guides Channel](https://www.youtube.com/channel/UCP7RrmoueENv9TZts3HXXtw)
* [GitKraken Support](https://support.gitkraken.com/)
* [Sourcetree Support](https://confluence.atlassian.com/get-started-with-sourcetree)
# GitHub
## What is GitHub?
GitHub makes it easier on us as human beings! GitHub is a cloud based management tool for your code.
Think of it like Google Docs' tracked changes feature. In any document, you can use tracked changes to *visualize* the changes you or someone else are making. In GitHub, we are using a similar way to visualize version control. This is extremely important when you start working in teams or on a large project. You will want to have changes to your code saved so that you can refer back if you need to.
## Setup
Navigate [here](https://desktop.github.com) to download GitHub Desktop and follow prompts.
Note: You will want to create an account and hold on to the email you use for this account.
# RStudio
## Setup
```{r install, message = FALSE, warning = FALSE}
library(usethis)
```
You should have the latest version of R and Rstudio downloaded. To check your current version of R:
```{r version}
R.version.string
```
You will also want to have git installed at this point. To introduce yourself to git using RStudio:
```{r git-config}
use_git_config(user.name = "Michelle Slawinski", user.email = "[email protected]")
#use.email should be the same as your GitHub account
```
To configure GitHub with RStudio, you will need to set up a token in RStudio. This is basically a secure connection between GitHub and RStudio:
```{r github-token}
usethis::create_github_token()
gitcreds::gitcreds_set
```
## RStudio Resources
* [An Introduction to Git and how to use it with RStudio](https://r-bio.github.io/intro-git-rstudio/)
* [GitHub and RStudio](https://resources.github.com/whitepapers/github-and-rstudio/)
* [Happy Git and GitHub for the useR](https://happygitwithr.com/connect-intro.html)
# Last Minute Things
## Dictionary
Term | Definition
---------|----------
Shell | A terminal that uses written commands to interact with your operating system
Git Directory | Umbrella terms for all of your files and folders
Modify | Changed the file but have not committed it to your local system
Staged/Indexed | Marked a modified file to go into your next commit snapshot
Commit | Save the state of your project in your local system
Branch | When you duplicate part of a repository
Merge | After you finish updating the code you branched, you can merge it back into the project's main source code
Push | Once you commit your project or file to your local system, you have the option to push it to remote GitHub
Pull | If your repository has new changes in GitHub, you can download and integrate those remote changes by using 'pull'
Fetch | To see if there are remote changes, you can use fetch to see what was updated. Fetch will not merge your updates though
## Tips
1. Update some basic profile features GitHub offers like a picture, occupation, or location! Click your picture in the top right corner after logging in and select 'Settings.'
1. You can also personalize your profile's ReadMe file with an introduction for people who will visit your page. This is again optional but helps you get noticed. If you want to see some super cool examples, beef up your profile with certain tools, or do some late night reading on how to make your profile stand out, look at this [repository](https://github.com/abhisheknaiidu/awesome-github-profile-readme)!
1. Make sure you have a ReadMe file for every repository. This serves as an executive summary for your project and saves viewers time on figuring out what the purpose of your project is.
1. When you make a commit, make sure you are descriptive, especially if you are working on a team. You can use git to search your commit messages so you'll want to be descriptive! Google 'git commit best practices' and you can look through all the suggestions on how to do this.
1. Branch this markdown file and add your own tips!
## Let's Practice
Now that you have an understanding of Git and GUIs such as GitHub, let's practice!
We will be practicing how to fork a repository from GitHub, make a change locally, then commit those changes and push them back to GitHub. Ready? Lets get our feet wet.
1. Navigate to [RLadies of Gainesville's GitHub](https://github.com/R-Ladies-Gainesville)
1. Locate and click on the "practice" repository
1. In the upper right hand corner, click "Fork"
Once you have it forked, you will see that it is in your remote GitHub. Now that you have it remotely, we will want to get access to it locally so that we can add to the repository.
1. Click into the 'practice' repository if you are not already in it and click on the 'Code" drop down.
1. Select Open with GitHub Desktop. Once you click this, GitHub Desktop should open with a screen asking you where you would like to place the repository on your desktop. Go ahead and find where you would like to put the repository.
1. At the top of GitHub Desktop, click the 'Current Branch' and choose 'New Branch.'
1. Name the branch your first and last name: MichelleSlawinski. There are also best practices for naming branches but it can also rely on what your team prefers.
1. Now open the 'GettingAroundGitHub_Participants' file in RStudio from the practice repository and follow the directions in there.
& that's it!