-<iclass="fa fa-youtube-play youtube"aria-hidden="true"></i> Watch the [GitLab Source Code Management Walkthrough](https://www.youtube.com/watch?v=wTQ3aXJswtM) video.
> - Learn how GitLab became the backbone of [Worldline](https://about.gitlab.com/customers/worldline/)'s development environment.
- Learn how [GitLab became the backbone of Worldline](https://about.gitlab.com/customers/worldline/)'s development environment.
NOTE:
NOTE:
To help you visualize what you're doing locally, there are
To help you visualize what you're doing locally, there are
[Git GUI apps](https://git-scm.com/download/gui/) you can install.
[Git GUI apps](https://git-scm.com/download/gui/) you can install.
## Requirements
## Prerequisites
You don't need a GitLab account to use Git locally, but for the purpose of this guide we
You don't need a GitLab account to use Git locally, but for the purpose of this guide we
recommend registering and signing into your account before starting. Some commands need a
recommend registering and signing into your account before starting. Some commands need a
connection between the files in your computer and their version on a remote server.
connection between the files on your computer and their version on a remote server.
You must also open a [command shell](#command-shell) and have
You must also open a [terminal](#open-a-terminal) and have
[Git installed](#install-git)in your computer.
[Git installed](#install-git)on your computer.
### Command shell
### Open a terminal
To execute Git commands in your computer, you must open a command shell (also known as command
To execute Git commands on your computer, you must open a terminal (also known as command
prompt, terminal, and command line) of your preference. Here are some suggestions:
prompt, command shell, and command line) of your preference. Here are some suggestions:
- For macOS users:
- For macOS users:
- Built-in: [Terminal](https://blog.teamtreehouse.com/introduction-to-the-mac-os-x-command-line). Press <kbd>⌘ command</kbd> + <kbd>space</kbd> and type "terminal" to find it.
- Built-in: [Terminal](https://blog.teamtreehouse.com/introduction-to-the-mac-os-x-command-line). Press <kbd>⌘ command</kbd> + <kbd>space</kbd> and type "terminal" to find it.
...
@@ -59,7 +58,7 @@ prompt, terminal, and command line) of your preference. Here are some suggestion
...
@@ -59,7 +58,7 @@ prompt, terminal, and command line) of your preference. Here are some suggestion
### Install Git
### Install Git
Open a command shell and run the following command to check if Git is already installed in your
Open a terminal and run the following command to check if Git is already installed in your
computer:
computer:
```shell
```shell
...
@@ -113,45 +112,35 @@ You have two options:
...
@@ -113,45 +112,35 @@ You have two options:
- Authenticate on a project-by-project basis through HTTPS, and enter your credentials every time
- Authenticate on a project-by-project basis through HTTPS, and enter your credentials every time
you perform an operation between your computer and GitLab.
you perform an operation between your computer and GitLab.
- Authenticate through SSH once and GitLab no longer requests your credentials every time you pull, push,
- Authenticate through SSH once and GitLab no longer requests your credentials every time you
and clone.
perform an operation between your computer and GitLab.
To start the authentication process, we'll [clone](#clone-a-repository) an existing repository
To start the authentication process, we'll [clone](#clone-a-repository) an existing repository
to our computer:
to our computer:
- If you want to use **SSH** to authenticate, follow the instructions on the [SSH documentation](../ssh/README.md)
- If you want to use **SSH** to authenticate, follow the instructions on the [SSH documentation](../ssh/README.md)
to set it up before cloning.
to set it up before cloning.
- If you want to use **HTTPS**, GitLab requests your username and password:
- If you want to use **HTTPS**, GitLab requests your username and password:
- If you have 2FA enabled for your account, you must use a [Personal Access Token](../user/profile/personal_access_tokens.md)
- If you have 2FA enabled for your account, you must use a [Personal Access Token](../user/profile/personal_access_tokens.md)
with **read_repository** or **write_repository** permissions instead of your account's password.
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.
- If you don't have 2FA enabled, use your account's password.
NOTE:
NOTE:
Authenticating via SSH is the GitLab recommended method. You can read more about credential storage
Authenticating through SSH is the GitLab 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).
in the [Git Credentials documentation](https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage).
## Git terminology
## Git terminology
If you're familiar with the Git terminology, you may want to jump directly
If you're familiar with Git terminology, you may want to jump directly
into the [basic commands](#basic-git-commands).
into [setting up a repository](#set-up-a-repository).
### 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
### Repository
Your files in GitLab live in a **repository**, similar to how you have them in a folder or
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
directory on your computer.
GitLab and the copy in your computer is called **local** copy.
A **project** in GitLab is what holds a repository, which holds your files.
-**Remote** repository refers to the files in GitLab.
- A **local** copy refers to the files on your computer.
<!-- vale gitlab.Spelling = NO -->
<!-- vale gitlab.Spelling = NO -->
<!-- vale gitlab.SubstitutionWarning = NO -->
<!-- vale gitlab.SubstitutionWarning = NO -->
...
@@ -159,22 +148,25 @@ Often, the word "repository" is shortened to "repo".
...
@@ -159,22 +148,25 @@ Often, the word "repository" is shortened to "repo".
<!-- vale gitlab.Spelling = YES -->
<!-- vale gitlab.Spelling = YES -->
<!-- vale gitlab.SubstitutionWarning = YES -->
<!-- vale gitlab.SubstitutionWarning = YES -->
A **project** in GitLab is what holds a repository.
### Fork
### Fork
When you want to copy someone else's repository, you [**fork**](../user/project/repository/forking_workflow.md#creating-a-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 create a copy of the project into your own
the project. By forking it, you create a copy of the project into your own
namespace to have read and write permissions to modify the project files
[namespace](../user/group/#namespaces) to have read and write permissions to modify the project files
and settings.
and settings.
For example, if you fork this project, <https://gitlab.com/gitlab-tests/sample-project/> into your namespace, you 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,
For example, if you fork this project, <https://gitlab.com/gitlab-tests/sample-project/> into your namespace,
work on its files, and (optionally) submit proposed changes back to the
you create your own copy of the repository in your namespace (`https://gitlab.com/your-namespace/sample-project/`).
original repository if you'd like.
From there, you can clone the repository, work on the files, and (optionally) submit proposed changes back to the
original repository.
### Download vs clone
### Difference between download and clone
To create a copy of a remote repository's files on your computer, you can either
To create a copy of a remote repository's files on your computer, you can either
**download** or **clone**. If you download, you cannot sync it with the
**download** or **clone** the repository. If you download it, you cannot sync the repository with the
remote repository on GitLab.
remote version on GitLab.
[Cloning](#clone-a-repository) a repository is the same as downloading, except it preserves the Git connection
[Cloning](#clone-a-repository) a repository is the same as downloading, except it preserves the Git connection
with the remote repository. This allows you to modify the files locally and
with the remote repository. This allows you to modify the files locally and
...
@@ -182,44 +174,42 @@ upload the changes to the remote repository on GitLab.
...
@@ -182,44 +174,42 @@ upload the changes to the remote repository on GitLab.
### Pull and push
### Pull and push
After you saved a local copy of a repository and modified its files on your computer, you can upload the
After you save a local copy of a repository and modify the files on your computer, you can upload the
changes to GitLab. This is referred to as **pushing** to GitLab, as this is achieved by the command
changes to GitLab. This is referred to as **pushing** to the remote, as this is achieved by the command
[`git push`](#send-changes-to-gitlabcom).
[`git push`](#send-changes-to-gitlabcom).
When the remote repository changes, your local copy is behind it. You can update it with the new
When the remote repository changes, your local copy is behind. You can update your local copy with the new
changes in the remote repository.
changes in the remote repository.
This is referred to as **pulling** from GitLab, as this is achieved by the command
This is referred to as **pulling** from the remote, as this is achieved by the command
project is available under `https://gitlab.com/<your-namespace>/sample-project/`.
Remember to replace the example URLs with the relevant path of your project.
You can also choose any other project to follow this guide. Then, replace the
To get started, choose one of the following:
example URLs with your own project's.
If you want to start by copying an existing GitLab repository onto your
- Use the example project by signing into GitLab.com and [forking](../user/project/repository/forking_workflow.md#creating-a-fork)
computer, see how to [clone a repository](#clone-a-repository). On the other
it into your namespace to make it available under `https://gitlab.com/<your-namespace>/sample-project/`.
hand, if you want to start by uploading an existing folder from your computer
- Copy an existing GitLab repository onto your computer by [cloning a repository](#clone-a-repository).
to GitLab, see how to [convert a local folder into a Git repository](#convert-a-local-directory-into-a-repository).
- Upload an existing folder from your computer to GitLab by [converting a local folder into a Git repository](#convert-a-local-directory-into-a-repository).
### Clone a repository
### Clone a repository
To start working locally on an existing remote repository, clone it with the
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)
command `git clone <repository path>`. You can either clone it using [HTTPS](#clone-using-https)
or [SSH](#clone-via-ssh), according to your preferred [authentication method](#git-authentication-methods).
or [SSH](#clone-using-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
You can find both paths (HTTPS and SSH) by navigating to your project's landing page
and clicking **Clone**. GitLab prompts you with both paths, from which you can copy
and clicking **Clone**. GitLab prompts you with both paths, from which you can copy
and paste in your command line. You can also
and paste in your command line. You can also
[clone and open directly in Visual Studio Code](../user/project/repository/index.md#clone-and-open-in-apple-xcode).
[clone and open directly in Visual Studio Code](../user/project/repository/index.md#clone-and-open-in-apple-xcode).
For example, considering our [sample project](https://gitlab.com/gitlab-tests/sample-project/):
For example, with our [sample project](https://gitlab.com/gitlab-tests/sample-project/):
- To clone through HTTPS, use `https://gitlab.com/gitlab-tests/sample-project.git`.
- To clone through HTTPS, use `https://gitlab.com/gitlab-tests/sample-project.git`.
- To clone through SSH, use `git@gitlab.com:gitlab-tests/sample-project.git`.
- To clone through SSH, use `git@gitlab.com:gitlab-tests/sample-project.git`.
...
@@ -232,22 +222,22 @@ name and preserve the connection with the remote repository.
...
@@ -232,22 +222,22 @@ name and preserve the connection with the remote repository.
You can then navigate to the new directory with `cd sample-project` and start working on it
You can then navigate to the new directory with `cd sample-project` and start working on it
locally.
locally.
#### Clone via HTTPS
#### Clone using HTTPS
To clone `https://gitlab.com/gitlab-tests/sample-project/`via HTTPS:
To clone `https://gitlab.com/gitlab-tests/sample-project/`using HTTPS: