Create a repository
Once you create a new project, you can add new files via UI (read the section below) or via command line. To add files from the command line, follow the instructions that will be presented on the screen when you create a new project, or read through them in the command line basics documentation.
Important: For security reasons, when using the command line, we strongly recommend that you connect with GitLab via SSH.
Create and edit files
Host your codebase in GitLab repositories by pushing your files to GitLab. You can either use the user interface (UI), or connect your local computer with GitLab through the command line.
From the user interface:
GitLab's UI allows you to perform lots of Git commands without having to touch the command line. Even if you use the command line regularly, sometimes it's easier to do so via GitLab UI:
- Create a file
- Upload a file
- File templates
- Create a directory
- Start a merge request
- Find file history
- Identify changes by line (Git blame)
From the command line:
To get started with the command line, please read through the command line basics documentation.
Use GitLab's file finder to search for files in a repository.
Supported markup languages and extensions
GitLab supports a number of markup languages (sometimes called lightweight markup languages) that you can use for the content of your files in a repository. They are mostly used for documentation purposes.
Just pick the right extension for your files and GitLab will render them according to the markup language.
Repository README and index files
index file is present in a repository, its contents will be
automatically pre-rendered by GitLab without opening it.
They can either be plain text or have an extension of a supported markup language:
Some things to note about precedence:
- When both a
indexfile are present, the
READMEwill always take precedence.
- When more than one file is present with different extensions, they are
ordered alphabetically, with the exception of a file without an extension
which will always be last in precedence. For example,
README.adocwill take precedence over
README.rstwill take precedence over
Jupyter Notebook files
Jupyter Notebook (previously IPython Notebook) files are used for interactive computing in many fields and contain a complete record of the user's sessions and include code, narrative text, equations, and rich output.
Introduced in GitLab 12.6.
GitLab can render OpenAPI specification files with its file viewer, provided
their filenames include
swagger and their extension is
json. The following examples are all correct:
Then, to render them:
- Navigate to the OpenAPI file in your repository in GitLab's UI.
- Click the "Display OpenAPI" button which is located between the "Display source" and "Edit" buttons (when an OpenAPI file is found, it replaces the "Display rendered file" button).
For details, see Branches.
When you commit your changes, you are introducing those changes to your branch. Via command line, you can commit multiple times before pushing.
A commit message is important to identity what is being changed and,
more importantly, why. In GitLab, you can add keywords to the commit
message that will perform one of the actions below:
- Trigger a GitLab CI/CD pipeline: If you have your project configured with GitLab CI/CD, you will trigger a pipeline per push, not per commit.
You can add to you commit message the keyword
[ci skip]and GitLab CI will skip that pipeline.
- Cross-link issues and merge requests: Cross-linking is great to keep track of what's is somehow related in your workflow. If you mention an issue or a merge request in a commit message, they will be shown on their respective thread.
- Cherry-pick a commit: In GitLab, you can cherry-pick a commit right from the UI.
- Revert a commit: Easily revert a commit from the UI to a selected branch.
- Sign a commit: Use GPG to sign your commits.
Project and repository size
A project's size is reported on the project's Details page. The reported size is updated every 15 minutes at most, so may not reflect recent activity. The displayed files size includes repository files, artifacts, and LFS.
The project size may differ slightly from one instance to another due to compression, housekeeping, and other factors.
All the contributors to your codebase are displayed under your project's Settings > Contributors.
They are ordered from the collaborator with the greatest number of commits to the fewest, and displayed on a nice graph:
The repository graph displays visually the Git flow strategy used in that repository:
Find it under your project's Repository > Graph.
For the default branch of each repository, GitLab will determine what programming languages were used and display this on the projects pages. If this information is missing, it will be added after updating the default branch on the project. This process can take up to 5 minutes.
Not all files are detected, among others; documentation,
vendored code, and most markup languages are excluded. This behaviour can be
adjusted by overriding the default. For example, to enable
.proto files to be
detected, add the following to
.gitattributes in the root of your repository.
Locked files (PREMIUM)
Use File Locking to lock your files to prevent any conflicting changes.
You can access your repos via repository API.
Clone in Apple Xcode
Introduced in GitLab 11.0
Projects that contain a
.xcworkspace directory can now be cloned
in Xcode using the new Open in Xcode button, located next to the Git URL
used for cloning your project. The button is only shown on macOS.
Download Source Code
Support for directory download was introduced in GitLab 11.11.
The source code stored in a repository can be downloaded from the UI. By clicking the download icon, a dropdown will open with links to download the following:
allows users to download the source code on branch they're currently
viewing. Available extensions:
only shows up when viewing a sub-directory. This allows users to download
the specific directory they're currently viewing. Also available in
- Artifacts: allows users to download the artifacts of the latest CI build.