Commit f9ea6e78 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents 23e19088 f4b2d8b9
---
comments: false
type: index
---
# GitLab basics guides
This section provides resources to help you start with GitLab by focusing on basic functionality.
This section provides resources to help you start working with GitLab and Git by focusing
on the basic features that you will need to use.
This documentation is split into the following groups:
- [GitLab-specific functionality](#gitlab-basics), for basic GitLab features.
- [General Git functionality](#git-basics), for working with Git in conjunction with GitLab.
- [General Git functionality](#working-with-git-from-the-command-line), for working
with Git in conjunction with GitLab.
## GitLab basics
......@@ -17,22 +20,26 @@ The following are guides to basic GitLab functionality:
- [Create and add your SSH public key](create-your-ssh-keys.md), for enabling Git over SSH.
- [Create a project](create-project.md), to start using GitLab.
- [Create a group](../user/group/index.md#create-a-new-group), to combine and administer projects together.
- [Create a group](../user/group/index.md#create-a-new-group), to combine and administer
projects together.
- [Create a branch](create-branch.md), to make changes to files stored in a project's repository.
- [Fork a project](fork-project.md), to duplicate projects so they can be worked on in parallel.
- [Add a file](add-file.md), to add new files to a project's repository.
- [Add an image](add-image.md), to add new images to a project's repository.
- [Create an issue](../user/project/issues/managing_issues.md#create-a-new-issue), to start collaborating within a project.
- [Create a merge request](add-merge-request.md), to request changes made in a branch be merged into a project's repository.
- See how these features come together in the [GitLab Flow introduction video](https://youtu.be/InKNIvky2KE) and [GitLab Flow page](../workflow/gitlab_flow.md).
- [Create an issue](../user/project/issues/managing_issues.md#create-a-new-issue),
to start collaborating within a project.
- [Create a merge request](add-merge-request.md), to request changes made in a branch
be merged into a project's repository.
- See how these features come together in the [GitLab Flow introduction video](https://youtu.be/InKNIvky2KE)
and [GitLab Flow page](../workflow/gitlab_flow.md).
## Git basics
## Working with Git from the command line
If you're familiar with Git on the command line, you can interact with your GitLab projects just as you would with any other Git repository.
If you're familiar with Git on the command line, you can interact with your GitLab
projects just as you would with any other Git repository.
These resources will help get further acclimated to working on the command line.
- [Start using Git on the command line](start-using-git.md), for some simple Git commands.
- [Command line basics](command-line-commands.md), to create and edit files using the command line.
More Git resources are available at GitLab's [Git documentation](../topics/git/index.md).
More Git resources are available in GitLab's [Git documentation](../topics/git/index.md).
# How to add a file
---
type: howto
---
You can create a file in your [terminal](command-line-commands.md) and push
to GitLab or you can use the
# Add a file to a repository
Adding files to a repository is a small, but key task. Bringing files in to a repository,
such as code, images, or documents, allows them to be tracked by Git, even though they
may have been created elsewhere.
You can add a file to a repository in your [terminal](#add-a-file-using-the-command-line), and
then push to GitLab. You can also use the [web interface](../user/project/repository/web_editor.md#upload-a-file),
which may be a simpler solution.
If you need to create a file first, for example a `README.md` text file, that can
also be done from the [terminal](command-line-commands.md#create-a-text-file-in-the-current-directory) or
[web interface](../user/project/repository/web_editor.md#create-a-file).
## Add a file using the command line
Open a [terminal/shell](command-line-commands.md), and change into the folder of your
GitLab project. This usually means running the following command until you get
to the desired destination:
```sh
cd <destination folder>
```
[Create a branch](create-branch.md) to add your file to, before it is added to the master
(main) branch of the project. It is not strictly necessary, but working directly in
the `master` branch is not recommended unless your project is very small, and you are
the only person working on it. You can [switch to an existing branch](start-using-git.md#work-on-an-existing-branch),
if you have one already.
Using your standard tool for copying files (for example, Finder in macOS, or File Explorer
in Windows), put the file into a directory within the GitLab project.
Check if your file is actually present in the directory (if you are in Windows,
use `dir` instead):
```sh
ls
```
You should see the name of the file in the list shown.
Check the status:
```sh
git status
```
Your file's name should appear in red, so `git` took notice of it! Now add it
to the repository:
```sh
git add <name of file>
```
Check the status again, your file's name should have turned green:
```sh
git status
```
Commit (save) your file to the repository:
```sh
git commit -m "DESCRIBE COMMIT IN A FEW WORDS"
```
Now you can push (send) your changes (in the branch `<branch-name>`) to GitLab
(the git remote named 'origin'):
```sh
git push origin <branch-name>
```
Your image will be added to your branch in your repository in GitLab.
<!-- ## Troubleshooting
Include any troubleshooting steps that you can foresee. If you know beforehand what issues
one might have when setting this up, or when something is changed, or on upgrading, it's
important to describe those, too. Think of things that may go wrong and include them here.
This is important to minimize requests for support, and to avoid doc comments with
questions that you know someone might ask.
Each scenario can be a third-level heading, e.g. `### Getting error message X`.
If you have none to add when creating a doc, leave this section in place
but commented out to help encourage others to add to it in the future. -->
# How to add an image
---
redirect_to: 'add-file.md'
---
Using your standard tool for copying files (e.g. Finder in Mac OS, or Explorer
in Windows, or...), put the image file into the GitLab project. You can find the
project as a regular folder in your files.
Go to your [shell](command-line-commands.md), and move into the folder of your
GitLab project. This usually means running the following command until you get
to the desired destination:
```
cd NAME-OF-FOLDER-YOU'D-LIKE-TO-OPEN
```
Check if your image is actually present in the directory (if you are in Windows,
use `dir` instead):
```
ls
```
You should see the name of the image in the list shown.
Check the status:
```
git status
```
Your image's name should appear in red, so `git` took notice of it! Now add it
to the repository:
```
git add NAME-OF-YOUR-IMAGE
```
Check the status again, your image's name should have turned green:
```
git status
```
Commit:
```
git commit -m "DESCRIBE COMMIT IN A FEW WORDS"
```
Now you can push (send) your changes (in the branch NAME-OF-BRANCH) to GitLab
(the git remote named 'origin'):
```
git push origin NAME-OF-BRANCH
```
Your image will be added to your branch in your repository in GitLab.
This document was moved to [another location](add-file.md).
---
type: howto
---
# How to create a merge request
Merge requests are useful to integrate separate changes that you've made to a
project, on different branches. This is a brief guide on how to create a merge
request. For more information, check the
[merge requests documentation](../user/project/merge_requests/index.md).
Merge requests are how you integrate separate changes that you've made in a
[branch](create-branch.md) to a [project](create-project.md).
This is a brief guide on how to create a merge request. For more detailed information,
check the [merge requests documentation](../user/project/merge_requests/index.md), or
you can watch our [GitLab Flow video](https://www.youtube.com/watch?v=InKNIvky2KE) for
a quick overview of working with merge requests.
---
......@@ -12,19 +19,31 @@ request. For more information, check the
1. Go to the project where you'd like to merge your changes and click on the
**Merge requests** tab.
1. Click on **New merge request** on the right side of the screen.
1. From there on, you have the option to select the source branch and the target
1. From there, you have the option to select the source branch and the target
branch you'd like to compare to. The default target project is the upstream
repository, but you can choose to compare across any of its forks.
![Select a branch](img/merge_request_select_branch.png)
![Select a branch](img/merge_request_select_branch.png)
1. When ready, click on the **Compare branches and continue** button.
1. At a minimum, add a title and a description to your merge request. Optionally,
select a user to review your merge request and to accept or close it. You may
also select a milestone and labels.
select a user to review your merge request. You may also select a milestone and
labels.
![New merge request page](img/merge_request_page.png)
![New merge request page](img/merge_request_page.png)
1. When ready, click on the **Submit merge request** button.
Your merge request will be ready to be approved and merged.
Your merge request will be ready to be reviewed, approved, and merged.
<!-- ## Troubleshooting
Include any troubleshooting steps that you can foresee. If you know beforehand what issues
one might have when setting this up, or when something is changed, or on upgrading, it's
important to describe those, too. Think of things that may go wrong and include them here.
This is important to minimize requests for support, and to avoid doc comments with
questions that you know someone might ask.
Each scenario can be a third-level heading, e.g. `### Getting error message X`.
If you have none to add when creating a doc, leave this section in place
but commented out to help encourage others to add to it in the future. -->
# Basic Git commands
---
redirect_to: 'start-using-git.md'
---
This section is now merged into [Start using Git](start-using-git.md).
This document was moved to [another location](start-using-git.md).
# 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:
---
type: howto, reference
---
```
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
```
# Command Line basic commands
### Go back one directory
When [working with Git from the command line](start-using-git.md), you will need to
use more than just the Git commands. There are several basic commands that you should
learn, in order to make full use of the command line.
```
cd ..
```
## Start working on your project
### List what’s in the current directory
To work on a git project locally (from your own computer), with the command line,
first you will need to [clone (copy) it](start-using-git.md#clone-a-repository) to
your computer.
```
ls
```
## Working with files on the command line
### List what’s in the current directory that starts with `a`
This section has examples of some basic shell commands that you might find useful.
For more information, search the web for _bash commands_.
```
ls a*
```
Alternatively, you can edit files using your choice of editor (IDE), or the GitLab user
interface (not locally).
### List what’s in the current directory that ends with `.md`
### Common commands
```
ls *.md
```
The list below is not exhaustive, but contains many of the most commonly used commands.
### Create a new directory
| Command | Description |
|--------------------------------|---------------------------------------------|
| `cd NAME-OF-DIRECTORY` | Go into a directory to work in it |
| `cd ..` | Go back one directory |
| `ls` | List what’s in the current directory |
| `ls a*` | List what’s in the current directory that starts with `a` |
| `ls *.md` | List what’s in the current directory that ends with `.md` |
| `mkdir NAME-OF-YOUR-DIRECTORY` | Create a new directory |
| `cat README.md` | Display the contents of a [text file you created previously](#create-a-text-file-in-the-current-directory) |
| `pwd` | Show the current directory |
| `clear` | Clear the shell window |
```
mkdir NAME-OF-YOUR-DIRECTORY
```
### Create a text file in the current directory
### Create a README.md file in the current directory
To create a text file from the command line, for example `README.md`, follow these
steps:
```
touch README.md
......@@ -80,37 +52,37 @@ nano README.md
#### Press: enter
```
### Show the contents of the README.md file
### Remove a file or directory
```
cat README.md
```
### Remove a file
It is easy to delete (remove) a file or directory, but be careful:
DANGER: **Danger:**
This will permanently delete the file.
This will **permanently** delete a 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.
This will **permanently** delete a directory and **all** of its contents.
```
rm -r NAME-OF-DIRECTORY
```
### View command history
### View and Execute commands from history
You can view the history of all the commands you executed from the command line,
and then execute any of them again, if needed.
First, list the commands you executed previously:
```
history
```
### Execute command 123 from history
Then, choose a command from the list and check the number next to the command (`123`,
for example) . Execute the same full command with:
```
!123
......@@ -118,28 +90,32 @@ history
### Carry out commands for which the account you are using lacks authority
You will be asked for an administrator’s password.
Not all commands can be executed from a basic user account on a computer, you may
need administrator's rights to execute commands that affect the system, or try to access
protected data, for example. You can use `sudo` to execute these commands, but you
will likely be asked for an administrator password.
```
sudo COMMAND
sudo RESTRICTED-COMMAND
```
CAUTION: **Caution:**
Be careful of the commands you run with `sudo`. Certain commands may cause
damage to your data and system.
damage to your data or system.
### Show which directory I am in
## Sample Git taskflow
```
pwd
```
### Clear the shell window
If you are completely new to Git, looking through some [sample taskflows](https://rogerdudler.github.io/git-guide/)
will help you understand the best practices for using these commands as you work.
```
clear
```
<!-- ## Troubleshooting
### Sample Git taskflow
Include any troubleshooting steps that you can foresee. If you know beforehand what issues
one might have when setting this up, or when something is changed, or on upgrading, it's
important to describe those, too. Think of things that may go wrong and include them here.
This is important to minimize requests for support, and to avoid doc comments with
questions that you know someone might ask.
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.
Each scenario can be a third-level heading, e.g. `### Getting error message X`.
If you have none to add when creating a doc, leave this section in place
but commented out to help encourage others to add to it in the future. -->
---
type: howto
---
# How to create a branch
A branch is an independent line of development.
A branch is an independent line of development in a [project](../user/project/index.md).
New commits are recorded in the history for the current branch, which results
in taking the source from someone’s repository (the place where the history of
your work is stored) at certain point in time, and apply your own changes to it
in the history of the project.
When you create a new branch (in your [terminal](basic-git-commands.md) or with
[the web interface](../user/project/repository/web_editor.md#create-a-new-branch)),
you are creating a snapshot of a certain branch, usually the main `master` branch,
at it's current state. From there, you can start to make your own changes without
affecting the main codebase. The history of your changes will be tracked in your branch.
To add changes to your GitLab project, you should create a branch. You can do
it in your [terminal](basic-git-commands.md) or by
[using the web interface](../user/project/repository/web_editor.md#create-a-new-branch).
When your changes are ready, you then merge them into the rest of the codebase with a
[merge request](add-merge-request.md).
# Create a project
---
type: howto
---
[Projects](../user/project/index.md) combine many features of GitLab together.
# Creating projects
NOTE: **Note:**
For a list of words that cannot be used as project names see
[Reserved project and group names](../user/reserved_names.md).
Most work in GitLab is done within a [Project](../user/project/index.md). Files and
code are saved in projects, and most features are used within the scope of projects.
## Create a project in GitLab
To create a project in GitLab:
......@@ -14,11 +17,14 @@ To create a project in GitLab:
- Create a [blank project](#blank-projects).
- Create a project using with one of the available [project templates](#project-templates).
- [Import a project](../user/project/import/index.md) from a different repository,
if enabled on your GitLab instance. Contact your GitLab admin if this
is unavailable.
if enabled on your GitLab instance. Contact your GitLab admin if this is unavailable.
- Run [CI/CD pipelines for external repositories](../ci/ci_cd_for_external_repos/index.md). **(PREMIUM)**
## Blank projects
NOTE: **Note:**
For a list of words that cannot be used as project names see
[Reserved project and group names](../user/reserved_names.md).
### Blank projects
To create a new blank project on the **New project** page:
......@@ -37,23 +43,25 @@ To create a new blank project on the **New project** page:
can be cloned.
1. Click **Create project**.
## Project templates
### Project templates
Project templates can pre-populate your project with necessary files to get you started quickly.
Project templates can pre-populate a new project with the necessary files to get you
started quickly.
There are two types of project templates:
- [Built-in templates](#built-in-templates), sourced from the following groups:
- [`project-templates`](https://gitlab.com/gitlab-org/project-templates)
- [`pages`](https://gitlab.com/pages)
- [Custom project templates](#custom-project-templates-premium-only), for custom templates configured by GitLab administrators and users.
- [Custom project templates](#custom-project-templates-premium-only), for custom templates
configured by GitLab administrators and users.
### Built-in templates
#### Built-in templates
Built-in templates are project templates that are:
- Developed and maintained in the
[`project-templates`](https://gitlab.com/gitlab-org/project-templates) and [`pages`](https://gitlab.com/pages) groups.
- Developed and maintained in the [`project-templates`](https://gitlab.com/gitlab-org/project-templates)
and [`pages`](https://gitlab.com/pages) groups.
- Released with GitLab.
To use a built-in template on the **New project** page:
......@@ -62,22 +70,25 @@ To use a built-in template on the **New project** page:
1. From the list of available built-in templates, click the:
- **Preview** button to look at the template source itself.
- **Use template** button to start creating the project.
1. Finish creating the project by filling out the project's details. The process is the same as for
using a [blank project](#blank-projects).
1. Finish creating the project by filling out the project's details. The process is
the same as creating a [blank project](#blank-projects).
TIP: **Tip:**
You can improve the existing built-in templates or contribute new ones on the
[`project-templates`](https://gitlab.com/gitlab-org/project-templates) and [`pages`](https://gitlab.com/pages) groups.
You can improve the existing built-in templates or contribute new ones in the
[`project-templates`](https://gitlab.com/gitlab-org/project-templates) and
[`pages`](https://gitlab.com/pages) groups.
### Custom project templates **(PREMIUM ONLY)**
#### Custom project templates **(PREMIUM ONLY)**
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/6860) in
[GitLab Premium](https://about.gitlab.com/pricing) 11.2.
Creating new projects based on custom project templates is a convenient option to bootstrap a project.
Creating new projects based on custom project templates is a convenient option to
bootstrap a project.
Custom projects are available from the **Instance** or **Group** tabs under the **Create from template** tab,
depending on the type of template.
Custom projects are available at the [instance-level](../user/admin_area/custom_project_templates.md)
from the **Instance** tab, or at the [group-level](../user/group/custom_project_templates.md)
from the **Group** tab, under the **Create from template** tab.
To use a custom project template on the **New project** page:
......@@ -85,23 +96,19 @@ To use a custom project template on the **New project** page:
1. From the list of available custom templates, click the:
- **Preview** button to look at the template source itself.
- **Use template** button to start creating the project.
1. Finish creating the project by filling out the project's details. The process is the same as for
using a [blank project](#blank-projects).
For information on configuring custom project templates, see:
- [Custom instance-level project templates](../user/admin_area/custom_project_templates.md), for instance-level templates.
- [Custom group-level project templates](../user/group/custom_project_templates.md), for group-level templates.
1. Finish creating the project by filling out the project's details. The process is
the same as creating a [blank project](#blank-projects).
## Push to create a new project
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/26388) in GitLab 10.5.
When you create a new repo locally, instead of going to GitLab to manually
create a new project and then push the repo, you can directly push it to
GitLab to create the new project, all without leaving your terminal. If you have access to that
namespace, we will automatically create a new project under that GitLab namespace with its
visibility set to Private by default (you can later change it in the [project's settings](../public_access/public_access.md#how-to-change-project-visibility)).
When you create a new repository locally, instead of going to GitLab to manually
create a new project and then [clone the repo](start-using-git.md#clone-a-repository)
locally, you can directly push it to GitLab to create the new project, all without leaving
your terminal. If you have access rights to the associated namespace, GitLab will
automatically create a new project under that GitLab namespace with its visibility
set to Private by default (you can later change it in the [project's settings](../public_access/public_access.md#how-to-change-project-visibility)).
This can be done by using either SSH or HTTPS:
......@@ -127,3 +134,15 @@ remote: To view the project, visit:
remote: https://gitlab.example.com/namespace/nonexistent-project
remote:
```
<!-- ## Troubleshooting
Include any troubleshooting steps that you can foresee. If you know beforehand what issues
one might have when setting this up, or when something is changed, or on upgrading, it's
important to describe those, too. Think of things that may go wrong and include them here.
This is important to minimize requests for support, and to avoid doc comments with
questions that you know someone might ask.
Each scenario can be a third-level heading, e.g. `### Getting error message X`.
If you have none to add when creating a doc, leave this section in place
but commented out to help encourage others to add to it in the future. -->
# Create and add your SSH public key
---
type: howto
---
This topic describes how to:
# Create and add your SSH public key
- Create an SSH key pair to use with GitLab.
- Add the SSH public key to your GitLab account.
It is best practice to use [Git over SSH instead of Git over HTTP](https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols).
In order to use SSH, you will need to
You do this to use [Git over SSH instead of Git over HTTP](https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols).
1. [Create an SSH key pair](#creating-your-ssh-key-pair) on your local computer.
1. [Add the key to GitLab](#adding-your-ssh-public-key-to-gitlab).
## Creating your SSH key pair
1. Go to your [command line](start-using-git.md).
1. Follow the [instructions](../ssh/README.md#generating-a-new-ssh-key-pair) to generate your SSH key pair.
1. Go to your [command line](start-using-git.md#open-a-shell).
1. Follow the [instructions](../ssh/README.md#generating-a-new-ssh-key-pair) to generate
your SSH key pair.
## Adding your SSH public key to GitLab
To add the SSH public key to GitLab,
see [Adding an SSH key to your GitLab account](../ssh/README.md#adding-an-ssh-key-to-your-gitlab-account).
To add the SSH public key to GitLab, see
[Adding an SSH key to your GitLab account](../ssh/README.md#adding-an-ssh-key-to-your-gitlab-account).
NOTE: **Note:**
Once you add a key, you cannot edit it. If the paste
[didn't work](../ssh/README.md#testing-that-everything-is-set-up-correctly), you need to remove the key and re-add it.
Once you add a key, you cannot edit it. If it didn't paste properly, it
[will not work](../ssh/README.md#testing-that-everything-is-set-up-correctly), and
you will need to remove the key from GitLab and try adding it again.
---
type: howto
---
# How to fork a project
A fork is a copy of an original repository that you put in another namespace
where you can experiment and apply changes that you can later decide whether or
not to share, without affecting the original project.
It takes just a few steps to fork a project in GitLab.
1. Go to a project's dashboard under the **Project** tab and click on the
**Fork** button.
![Click on Fork button](img/fork_new.png)
1. You will be asked where to fork the repository. Click on the user or group
to where you'd like to add the forked project.
![Choose namespace](img/fork_choose_namespace.png)
1. After a few moments, depending on the repository's size, the forking will
complete.
It takes just a few steps to [fork a project in GitLab](../workflow/forking_workflow.md#creating-a-fork).
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment