gitlab-org--gitlab-foss/doc/gitlab-basics/command-line-commands.md

94 lines
1.7 KiB
Markdown
Raw Normal View History

2015-06-29 22:03:17 -04:00
# Command Line basic commands
## Start working on your project
2015-07-31 11:21:53 -04: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.
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
[setup](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 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)
2015-06-29 21:53:51 -04:00
## On the command line
### Clone your project
Go to your computer's shell and type the following command:
2015-06-30 15:45:21 -04:00
```
git clone PASTE HTTPS OR SSH HERE
```
A clone of the project will be created in your computer.
2015-06-30 15:45:21 -04:00
### Go into a project, directory or file to work in it
2015-06-30 15:45:21 -04:00
```
cd NAME-OF-PROJECT-OR-FILE
```
### Go back one directory or file
```
2015-06-30 15:45:21 -04:00
cd ../
```
### View whats in the directory that you are in
2015-06-30 15:45:21 -04:00
```
ls
```
### Create a directory
2015-06-30 15:45:21 -04:00
```
mkdir NAME-OF-YOUR-DIRECTORY
```
### Create a README.md or file in directory
2015-06-30 15:45:21 -04:00
```
touch README.md
nano README.md
#### ADD YOUR INFORMATION
#### Press: control + X
#### Type: Y
#### Press: enter
```
### Remove a file
2015-06-30 15:45:21 -04:00
```
rm NAME-OF-FILE
```
### Remove a directory and all of its contents
2015-06-30 15:45:21 -04:00
```
rm -rf NAME-OF-DIRECTORY
```
### View history in the command line
2015-06-30 15:45:21 -04:00
```
history
```
### Carry out commands for which the account you are using lacks authority
You will be asked for an administrators password.
2015-06-30 15:45:21 -04:00
```
sudo
```
2015-08-26 00:57:10 -04:00
### Tell where you are
2015-08-26 00:57:10 -04:00
```
pwd
```