-
Notifications
You must be signed in to change notification settings - Fork 25
/
installing-git.qmd
137 lines (74 loc) · 6.6 KB
/
installing-git.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
# Installing Git {#sec-terminal-git}
We recommend using Git via the Unix command line interface. For this we will need a terminal. The terminal is integrated into Mac and Linux systems, but Windows users will have to install an _emulator_. There are many emulator options available, but here we show how to install Git Bash because it can be done as part of the Windows Git installation. Because of the differences in Mac and Windows, the sections in this chapter are divided accordingly.
## Accessing the terminal on a Mac {#sec-terminal-on-mac}
In @sec-unix we will show how the terminal is our window into the Unix world. On a Mac you can access a terminal by opening the application in the Utilities folder:
::: {layout-ncol=2}
![](img/mac-screenshots/Screen-Shot-2018-04-11-at-10.35.44-AM.png){width=20%}
![](img/mac-screenshots/Screen-Shot-2018-04-11-at-10.36.29-AM.png){width=50%}
:::
You can also use the Spotlight feature on the Mac by typing command-spacebar, then type _Terminal_.
Yet another way to access the terminal is from RStudio. In the _Console_ pane you should see a _Terminal_ tab. If you click on this tab you will open a terminal window.
## Installing Git on the Mac
:::{.calout-warning}
The instructions in this subsection are not for Windows users.
:::
1. Start by opening a terminal as described in the previous section.
2. Once you start the terminal, you will see a console like this:
![](img/mac-screenshots/Screen-Shot-2018-04-11-at-10.36.48-AM.png){width=70% fig-align="center"}
3. You might have Git installed already. One way to check is by asking for the version by typing:
```
git --version
```
If you get a version number back, it is already installed. If not, you will get the following message:
![](img/mac-screenshots/Screen-Shot-2018-04-11-at-10.39.31-AM.png){width=70% fig-align="center"}
and you will be asked if you want to install it. You should click _Install_:
![](img/mac-screenshots/Screen-Shot-2018-04-11-at-10.39.44-AM.png){width=70% fig-align="center"}
4. This will take you through the installation process:
::: {layout-ncol=3}
![](img/mac-screenshots/Screen-Shot-2018-04-11-at-10.40.09-AM.png){width=33%}
![](img/mac-screenshots/Screen-Shot-2018-04-11-at-10.40.15-AM.png){width=33%}
![](img/mac-screenshots/Screen-Shot-2018-04-11-at-11.10.29-AM.png){width=33%}
:::
5. Once installed, you can check for the version again and it should show you something like this:
![](img/mac-screenshots/Screen-Shot-2018-04-11-at-11.10.47-AM.png){width=70% fig-align="center"}
Congratulations. You have installed Git on your Mac.
## Installing Git and Git Bash on Windows
:::{.callout-warning}
The instructions in this section are not for Mac users.
:::
There are several pieces of software that will permit you to perform Unix commands on Windows. We will be using Git Bash as it interfaces with RStudio and it is automatically installed when we install Git for Windows.
1. Start by searching for _Git for Windows_ on your browser and clicking on the link from _git-scm.com_^[<https://git-scm.com/download/win>].
![](img/windows-screenshots/VirtualBox_Windows-7-Enterprise_23_03_2018_09_31_15.png){width=70% fig-align="center"}
2. This will take you to the _Download Git_ page from which you can download the _most recent maintained build_:
![](img/windows-screenshots/VirtualBox_Windows-7-Enterprise_23_03_2018_09_31_45.png){width=70% fig-align="center"}
3. You can then accept to run the installer and agree to the license:
:::{layout-ncol=2}
![](img/windows-screenshots/VirtualBox_Windows-7-Enterprise_23_03_2018_09_32_01.png){width=35%}
![](img/windows-screenshots/VirtualBox_Windows-7-Enterprise_23_03_2018_09_32_10.png){width=35%}
:::
4. In one of the installation steps, you will be asked to pick the default editor for Git. Unless you are already a _vi_ or _vim_ user, we recommend against selecting _vim_ which might be the default. If you do not recognize an editor you are familiar with among the options given, we recommend that you select _nano_ as your default editor for Git since it is the easiest to learn:
![](img/windows-screenshots/VirtualBox_Windows-7-Enterprise_23_03_2018_09_32_55.png){width=70% fig-align="center"}
5. The next installation decision is actually an **important one**. This installation process installs Git Bash. We recommend that you select _Use Git and optional Unix tools from the Windows Command Prompt_ as this will permit you to learn Unix from within RStudio. However, if you do this, **some commands that run on your Windows command line will stop working**. If you do not use your Windows command line, then this should not be a problem. Also, most, if not all, of these Windows command lines have a Unix equivalent that you will be able to use now.
![](img/windows-screenshots/VirtualBox_Windows-7-Enterprise_23_03_2018_09_34_52.png){width=70% fig-align="center"}
6. You can now continue selecting the default options.
:::{layout-ncol=3}
![](img/windows-screenshots/VirtualBox_Windows-7-Enterprise_23_03_2018_09_35_03.png){width=23%}
![](img/windows-screenshots/VirtualBox_Windows-7-Enterprise_23_03_2018_09_35_29.png){width=23%}
![](img/windows-screenshots/VirtualBox_Windows-7-Enterprise_23_03_2018_09_35_42.png){width=23%}
![](img/windows-screenshots/VirtualBox_Windows-7-Enterprise_23_03_2018_09_35_57.png){width=23%}
![](img/windows-screenshots/VirtualBox_Windows-7-Enterprise_23_03_2018_09_36_43.png){width=23%}
:::
You have now installed Git on Windows.
## Accessing the terminal on Windows {#sec-terminal-on-windows}
Now that Git Bash is installed, we can access the terminal either through RStudio or by opening Git Bash directly.
To access the terminal through RStudio, we need to change a preference so that Git Bash becomes the default Unix shell in RStudio. In RStudio, go to preferences (under the File pull down menu), then select _Terminal_, then select _Git Bash_:
![](img/windows-screenshots/VirtualBox_Windows-7-Enterprise_23_03_2018_09_38_00.png){width=70% fig-align="center"}
To check that you in fact are using Git Bash in RStudio, you can open a _New Terminal_ in RStudio:
![](img/windows-screenshots/VirtualBox_Windows-7-Enterprise_23_03_2018_10_49_44.png){width=70% fig-align="center"}
It should look something like this:
![](img/windows-screenshots/VirtualBox_Windows-7-Enterprise_23_03_2018_10_49_51.png){width=70% fig-align="center"}
Often we want access to the terminal, but do not need RStudio. You can do this by running the Git Bash program directly:
:::{layout-ncol=2}
![](img/windows-screenshots/VirtualBox_Windows-7-Enterprise_23_03_2018_14_53_10.png){width=35%}
![](img/windows-screenshots/VirtualBox_Windows-7-Enterprise_23_03_2018_14_53_12.png){width=35%}
:::