Start using Git via the command line with the most basic commands as described below.
To connect your computer with GitLab, you need to add your credentials to identify yourself.
You have two options:
### Initialize a local directory for Git version control
- Authenticate on a project-by-project basis through HTTPS, and enter your credentials every time
you perform an operation between your computer and GitLab.
- Authenticate through SSH once and GitLab won't ask your credentials every time you pull, push,
and clone.
If you have an existing local directory that you want to *initialize* for version
control, use the `init` command to instruct Git to begin tracking the directory:
To start the authentication process, we'll [clone](#clone-a-repository) an existing repository
to our computer:
```shell
git init
```
- If you want to use **SSH** to authenticate, follow the instructions on the [SSH documentation](../ssh/README.md)
to set it up before cloning.
- If you want to use **HTTPS**, GitLab will request your user name and password:
- If you have 2FA enabled for your account, you'll have to use a [Personal Access Token](../user/profile/personal_access_tokens.md)
with **read_repository** or **write_repository** permissions instead of your account's password.
Create one before cloning.
- If you don't have 2FA enabled, use your account's password.
This creates a `.git` directory that contains the Git configuration files.
NOTE: **Note:**
Authenticating via SSH is GitLab's recommended method. You can read more about credential storage
in the [Git Credentials documentation](https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage).
Once the directory has been initialized, you can [add a remote repository](#add-a-remote-repository)
and [send changes to GitLab.com](#send-changes-to-gitlabcom). You will also need to
[create a new project in GitLab](../gitlab-basics/create-project.md#push-to-create-a-new-project)
for your Git repository.
## Git terminology
### Clone a repository
If you're familiar with the Git terminology, you may want to jump directly
into the [basic commands](#basic-git-commands).
### Namespace
A **namespace** is either a **user name** or a **group name**.
For example, suppose Jo is a GitLab.com user and they chose their user name as
`jo`. You can see Jo's profile at `https://gitlab.com/jo`. `jo` is a namespace.
Jo also created a group in GitLab, and chose the path `test-group` for their
group. The group can be accessed under `https://gitlab.com/test-group`. `test-group` is a namespace.
### Repository
Your files in GitLab live in a **repository**, similar to how you have them in a folder or
directory in your computer. **Remote** repository refers to the files in
GitLab and the copy in your computer is called **local** copy.
A **project** in GitLab is what holds a repository, which holds your files.
Often, the word "repository" is shortened to "repo".
### Fork
When you want to copy someone else's repository, you [**fork**](../user/project/repository/forking_workflow.md#creating-a-fork)
the project. By forking it, you'll create a copy of the project into your own
namespace to have read and write permissions to modify the project files
and settings.
For example, if you fork this project, <https://gitlab.com/gitlab-tests/sample-project/> into your namespace, you'll create your own copy of the repository in your namespace (`https://gitlab.com/your-namespace/sample-project/`). From there, you can clone it into your computer,
work on its files, and (optionally) submit proposed changes back to the
original repository if you'd like.
### Download vs clone
To start working locally on an existing remote repository, clone it with the command
`git clone <repository path>`. By cloning a repository, you'll download a copy of its
files to your local computer, automatically preserving the Git connection with the
remote repository.
To create a copy of a remote repository files on your computer, you can either
**download** or **clone** it. If you download it, you cannot sync it with the
remote repository on GitLab.
You can either clone it via [HTTPS](#clone-via-https) or [SSH](#clone-via-ssh). If you chose to
clone it via HTTPS, you'll have to enter your credentials every time you pull and push.
To use it, log into GitLab.com and fork the example project into your
namespace to have your own copy to playing with. Your sample
project will be available under `https://gitlab.com/<your-namespace>/sample-project/`.
You can also choose any other project to follow this guide. Then, replace the
example URLs with your own project's.
If you want to start by copying an existing GitLab repository onto your
computer, see how to [clone a repository](#clone-a-repository). On the other
hand, if you want to start by uploading an existing folder from your computer
to GitLab, see how to [convert a local folder into a Git repository](#convert-a-local-directory-into-a-repository).
### Clone a repository
To start working locally on an existing remote repository, clone it with the
command `git clone <repository path>`. You can either clone it via [HTTPS](#clone-via-https) or [SSH](#clone-via-ssh), according to your preferred [authentication method](#git-authentication-methods).
You can find both paths (HTTPS and SSH) by navigating to your project's landing page
and clicking **Clone**. GitLab will prompt you with both paths, from which you can copy
and paste in your command line.
As an example, consider this repository path:
For example, considering our [sample project](https://gitlab.com/gitlab-tests/sample-project/):