2015-06-30 02:03:17 +00:00
# Command Line basic commands
2015-06-25 15:45:37 +00:00
## Start working on your project
2015-07-31 15:21:53 +00:00
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.
2015-06-25 15:45:37 +00:00
2016-10-10 20:18:06 +00:00
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
2018-06-12 07:51:11 +00:00
[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_
2016-10-10 20:18:06 +00:00
button (you'll have to paste it on your shell in the next step).
2015-06-25 15:45:37 +00:00
2016-10-10 20:18:06 +00:00
![Copy the HTTPS or SSH ](img/project_clone_url.png )
2015-06-25 15:45:37 +00:00
2019-05-01 17:24:50 +00:00
## Working with project files on the command line
2015-06-25 15:45:37 +00:00
2018-06-12 07:51:11 +00:00
This section has examples of some basic shell commands that you might find useful. For more information, search the web for _bash commands_ .
2019-05-01 17:24:50 +00:00
Alternatively, you can edit files using your choice of editor (IDE) or the GitLab user interface.
2015-07-09 22:33:42 +00:00
### Clone your project
2016-10-10 20:18:06 +00:00
2018-06-12 07:51:11 +00:00
Go to your computer's shell and type the following command with your SSH or HTTPS URL:
2016-10-10 20:18:06 +00:00
2015-06-30 19:45:21 +00:00
```
git clone PASTE HTTPS OR SSH HERE
```
2015-07-09 22:33:42 +00:00
A clone of the project will be created in your computer.
2015-06-30 19:45:21 +00:00
2019-06-27 17:53:48 +00:00
NOTE: **Note:**
If you clone your project via a URL that contains special characters, make sure
that characters are URL-encoded.
2017-02-02 20:11:45 +00:00
2018-06-12 07:51:11 +00:00
### Go into a project directory to work in it
2016-10-10 20:18:06 +00:00
2015-06-30 19:45:21 +00:00
```
2018-06-12 07:51:11 +00:00
cd NAME-OF-PROJECT
2015-06-30 19:45:21 +00:00
```
2015-06-25 15:45:37 +00:00
2018-06-12 07:51:11 +00:00
### Go back one directory
2016-10-10 20:18:06 +00:00
2015-06-25 15:45:37 +00:00
```
2018-06-12 07:51:11 +00:00
cd ..
2015-06-25 15:45:37 +00:00
```
2018-06-12 07:51:11 +00:00
### List what’ s in the current directory
2016-10-10 20:18:06 +00:00
2015-06-30 19:45:21 +00:00
```
ls
```
2018-06-12 07:51:11 +00:00
### 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
2016-10-10 20:18:06 +00:00
2015-06-30 19:45:21 +00:00
```
mkdir NAME-OF-YOUR-DIRECTORY
```
2018-06-12 07:51:11 +00:00
### Create a README.md file in the current directory
2016-10-10 20:18:06 +00:00
2015-06-30 19:45:21 +00:00
```
touch README.md
nano README.md
#### ADD YOUR INFORMATION
#### Press: control + X
#### Type: Y
#### Press: enter
```
2018-06-12 07:51:11 +00:00
### Show the contents of the README.md file
```
cat README.md
```
2015-07-09 22:33:42 +00:00
### Remove a file
2016-10-10 20:18:06 +00:00
2019-06-27 17:53:48 +00:00
DANGER: **Danger:**
This will permanently delete the file.
2015-06-30 19:45:21 +00:00
```
rm NAME-OF-FILE
```
2015-07-09 22:33:42 +00:00
### Remove a directory and all of its contents
2016-10-10 20:18:06 +00:00
2019-06-27 17:53:48 +00:00
DANGER: **Danger:**
This will permanently delete the directory and all of its contents.
2015-06-30 19:45:21 +00:00
```
2018-03-27 14:12:20 +00:00
rm -r NAME-OF-DIRECTORY
2015-06-30 19:45:21 +00:00
```
2018-06-12 07:51:11 +00:00
### View command history
2016-10-10 20:18:06 +00:00
2015-06-30 19:45:21 +00:00
```
history
```
2018-06-12 07:51:11 +00:00
### Execute command 123 from history
```
!123
```
2015-07-09 22:33:42 +00:00
### Carry out commands for which the account you are using lacks authority
2016-10-10 20:18:06 +00:00
2015-07-09 22:33:42 +00:00
You will be asked for an administrator’ s password.
2016-10-10 20:18:06 +00:00
2015-06-30 19:45:21 +00:00
```
2019-06-27 17:53:48 +00:00
sudo COMMAND
2015-06-30 19:45:21 +00:00
```
2015-08-26 04:57:10 +00:00
2019-06-27 17:53:48 +00:00
CAUTION: **Caution:**
Be careful of the commands you run with `sudo` . Certain commands may cause
damage to your data and system.
2018-06-12 07:51:11 +00:00
### Show which directory I am in
2016-10-10 20:18:06 +00:00
2015-08-26 04:57:10 +00:00
```
pwd
```
2018-06-12 07:51:11 +00:00
### Clear the shell window
```
clear
```
2018-09-14 23:13:39 +00:00
### 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.