-
Notifications
You must be signed in to change notification settings - Fork 1
/
github.qmd
147 lines (87 loc) · 3.47 KB
/
github.qmd
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
---
title: "github"
---
## Resources
- https://raps-with-r.dev/git.html
- https://happygitwithr.com/
- https://learngitbranching.js.org/?locale=en_US
# summary
- Git is file versioning system that allows users to track additions,
deletions, and modifications to file.
- It is has many advantages relative to a traditional file save in that
you can walk up and down the various "states" of your file allowing
collaborators to transparently see coding modifications
- As with any new framework -- it takes time to learn the nuances, best
practices and other pitfalls before this workflow becomes useful
- Consistent with learning any new skill, this will be your journey
- Incredible frustration to initiate, setup and connect your code base
to your git repository
- High learning curve to adopt basic workflow
- Excitement after basic workflow works
- Insane frustration when you need do something other than your basic
workflow because now you have high learning curve to learn intermediate and
even advanced skills
- Confidence in using git and you are now saving time and energy to
offset your initial investment
- Destroyed confidence when you realize you can't do what you thought
was a basic task
- Repeat cycle
# How does it work?
- You are essentially pushing a version of your file /data to the cloud so
there exists two version -- one on your local machine and another in the cloud
- You work on your local machine, and "push" your work via "commits" to cloud
- Then when you start a new session, you "pull" the version from the cloud
and continue your work, edits / deletions
# Introduction
- Create your git account on one of the git sites (eg. github, gitlab or
gitbucket)
- It is often times easier to create your first repo (short for repository)
in github first and then connect and push files from your local machine
- First set your user name and email address
- You can do this with command line interface ("cli") arguments
- While intimidating, I do recommend you get comfortable with CLI arguments
```{bash}
#| eval: false
git config --global user.name 'alejandrohagan'
git config --global user.email '[email protected]'
git config --global --list
```
- Or you can use r package usethis to do this
2. if you need a PAT you store it below (thjs will also let you view it and run it)
```{r}
#| eval: false
# set creditential using this
gitcreds::gitcreds_set()
# check using this
gitcreds::gitcreds_get()
# validate who you are
gh::gh_whoami()
usethis::git_sitrep()
```
```{r}
```
## connect to a repo
## pull, committ and push
git pull to pull latest copy from the origin
Try to do this immediately as it makes merge conflicts less (in case you edit a file that is updated in the origin )
Then you `git add .` too add all changed documents are specifically specific
Then use `git` commit -m "message"`
- Make messages meaningful focuses on what and why -- helps with merge
- You can use `git status` to see status of things and `git log` to see past commands
## reversing / undoing
## branching / merging
add branch
- `git checkout branch "branch name"`
delete branch
- `git brand -d "branch name"`
delete cached item
```{}
git rm -rf --cached /home/hagan/R/learningR/data
```
# cant store PAT for linux so put it in your environ()
```{r}
usethis::edit_r_environ()
```
GITHUB_PAT=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-45 blue
-36 burges