blob: b8ebbbea9d416ce8954265e03ef2cd358a730950 (
plain)
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
|
# Command Line basic commands
## Start working on your project
In Git, when you copy a project you say you "clone" it. To work on a git project locally (from your own computer), you will need to clone it. To do this, sign in to GitLab.
When you are on your Dashboard, click on the project that you'd like to clone.
To work in the project, you can copy a link to the Git repository through a SSH
or a HTTPS protocol. SSH is easier to use after it's been
[set up](create-your-ssh-keys.md). While you are at the **Project** tab, select
HTTPS or SSH from the dropdown menu and copy the link using the _Copy URL to clipboard_
button (you'll have to paste it on your shell in the next step).
![Copy the HTTPS or SSH](img/project_clone_url.png)
## Working with project files on the command line
This section has examples of some basic shell commands that you might find useful. For more information, search the web for _bash commands_.
Alternatively, you can edit files using your choice of editor (IDE) or the GitLab user interface.
### Clone your project
Go to your computer's shell and type the following command with your SSH or HTTPS URL:
```
git clone PASTE HTTPS OR SSH HERE
```
A clone of the project will be created in your computer.
NOTE: **Note:**
If you clone your project via a URL that contains special characters, make sure
that characters are URL-encoded.
### Go into a project directory to work in it
```
cd NAME-OF-PROJECT
```
### Go back one directory
```
cd ..
```
### List what’s in the current directory
```
ls
```
### List what’s in the current directory that starts with `a`
```
ls a*
```
### List what’s in the current directory that ends with `.md`
```
ls *.md
```
### Create a new directory
```
mkdir NAME-OF-YOUR-DIRECTORY
```
### Create a README.md file in the current directory
```
touch README.md
nano README.md
#### ADD YOUR INFORMATION
#### Press: control + X
#### Type: Y
#### Press: enter
```
### Show the contents of the README.md file
```
cat README.md
```
### Remove a file
DANGER: **Danger:**
This will permanently delete the file.
```
rm NAME-OF-FILE
```
### Remove a directory and all of its contents
DANGER: **Danger:**
This will permanently delete the directory and all of its contents.
```
rm -r NAME-OF-DIRECTORY
```
### View command history
```
history
```
### Execute command 123 from history
```
!123
```
### Carry out commands for which the account you are using lacks authority
You will be asked for an administrator’s password.
```
sudo COMMAND
```
CAUTION: **Caution:**
Be careful of the commands you run with `sudo`. Certain commands may cause
damage to your data and system.
### Show which directory I am in
```
pwd
```
### Clear the shell window
```
clear
```
### Sample Git taskflow
If you are completely new to Git, looking through some [sample taskflows](https://rogerdudler.github.io/git-guide/) will help you understand best practices for using these commands as you work.
|