forked from jennybc/happy-git-with-r
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-introduce-self-git.Rmd
43 lines (27 loc) · 2.43 KB
/
install-introduce-self-git.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
# Introduce yourself to Git {#hello-git}
In the shell (Appendix \@ref(shell)):
``` bash
git config --global user.name 'Jane Doe'
git config --global user.email '[email protected]'
git config --global --list
```
substituting your name and **the email associated with your GitHub account**.
The [usethis package](https://usethis.r-lib.org) offers an alternative approach. You can set your Git user name and email from within R:
```{r, eval = FALSE}
## install if needed (do this exactly once):
## install.packages("usethis")
library(usethis)
use_git_config(user.name = "Jane Doe", user.email = "[email protected]")
```
## More about `git config`
An easy way to get into a shell from RStudio is *Tools > Terminal* or *Tools > Shell*. More about the shell in the Appendix \@ref(shell).
Special Windows gotchas: If you are struggling on Windows, consider there are different types of shell and you might be in the wrong one. You want to be in a "Git Bash" shell, as opposed to Power Shell or the legacy `cmd.exe` command prompt. Read more in [the Appendix](#windows-shell-hell). This might also be a reason to do this configuration via the usethis package in R.
What user name should you give to Git? This does not have to be your GitHub user name, although it can be. Another good option is your actual first name and last name. If you commit from different machines, sometimes people work that info into the user name. Your commits will be labelled with this user name, so make it informative to potential collaborators and future you.
What email should you give to Git? This __must__ be the email associated with your GitHub account.
These commands return nothing. You can check that Git understood what you typed by looking at the output of `git config --global --list`.
### Configure the Git editor {#git-editor}
Another Git option that many people eventually configure is the editor. At some point, you will fail to give Git what it wants in terms of a commit message and it will kick you into an editor. This can be distressing, if it's not your editor of choice and you don't even know how to save and quit. You can enforce your will with something along these lines:
``` bash
git config --global core.editor "emacs"
```
Substitute your preferred editor for `"emacs"` here. Software Carpentry's Git lesson has a comprehensive listing of the exact `git config` command needed for [many combinations of OS and editor](http://swcarpentry.github.io/git-novice/02-setup/).