doc/user/project/repository/_index.md
{{< details >}}
{{< /details >}}
Your repository is a component of your GitLab project. You store your code in your repository, and track changes to it with version control.
Each repository is part of a GitLab project, and cannot exist without a GitLab project. Your project provides the configuration options for your repository.
To create a repository:
You can add files to a repository:
To add or upload a file from the GitLab UI:
<!-- Original source for this list: doc/user/project/repository/web_editor.md#upload-a-file --> <!-- For why we duplicated the info, see <https://gitlab.com/gitlab-org/gitlab/-/merge_requests/111072#note_1267429478> -->You can commit your changes to a branch in the repository. When you use the command line,
use git commit.
For information about how to use commits to improve communication and collaboration, trigger or skip pipelines, and reverting changes, see commits.
You can clone a repository using the:
To download a repository's source code as a compressed file:
In the top bar, select Search or go to and find your project.
Above the file list, select Code.
From the options, select the files you want to download:
Source code:
Download the source code from the current branch you're viewing.
Available extensions: zip, tar, tar.gz, and tar.bz2.
Directory:
Download a specific directory. Visible only when you view a subdirectory.
Available extensions: zip, tar, tar.gz, and tar.bz2.
Artifacts:
Download the artifacts from the latest CI/CD job.
The checksums of generated archives can change even if the repository itself doesn't change. For example, this occurs if Git or a third-party library that GitLab uses changes.
To view all repository files and folders at a specific Git revision, such as a commit SHA, branch name, or tag:
You can also view and browse files at a specific Git revision from the commits page.
GitLab detects programming languages used in the default branch. This information is displayed on the Project overview page.
When new files are added, this information can take up to five minutes to update.
Not all files are detected and listed on the Project overview page. Documentation, vendor code, and most markup languages are excluded. To view a list of supported files and languages, see supported data types.
To change this behavior and include additional file types in the default settings:
In your repository's root directory, create a file named .gitattributes.
Add a line that tells GitLab to include a specific file type. For example,
to enable .proto files, add the following:
*.proto linguist-detectable=true
This feature can use excessive CPU. If you experience an issue, see the excessive CPU use troubleshooting section.
You can view a line chart with the number of commits to the selected project branch over time, and line charts with the number of commits by each project member. For more information, see contributor analytics.
A repository graph displays a visual history of the repository network, including branches and merges. This graph helps you see the flow of changes in the repository.
To view the repository history graph, go to your project's Code > Repository graph.
When a repository path changes, GitLab handles the transition from the old location to the new one with a redirect.
When you rename a user, change a group path, or rename a repository:
After you change a path, you must update the existing URL in the following resources:
include:component,
otherwise pipelines fail with a syntax error. CI/CD component references can follow redirects.CODEOWNERS file.If it seems that a commit has gone "missing", search the sequence of pushes to a repository.
This Stack Overflow thread
describes how you can end up in this state without a force push. Another cause can be a misconfigured
server hook that changes a HEAD ref in a git reset operation.
If you look at the output from the sample code below for the target branch, you
see a discontinuity in the from/to commits as you step through the output.
The commit_from of each new push should equal the commit_to of the previous push.
A break in that sequence indicates one or more commits have been "lost" from the repository history.
Using the rails console,
the following example checks the last 100 pushes and prints the commit_from and commit_to entries:
p = Project.find_by_full_path('project/path')
p.events.pushed_action.last(100).each do |e|
printf "%-20.20s %8s...%8s (%s)", e.push_event_payload[:ref], e.push_event_payload[:commit_from], e.push_event_payload[:commit_to], e.author.try(:username)
end ; nil
Example output showing break in sequence at line 4:
master f21b07713251e04575908149bdc8ac1f105aabc3...6bc56c1f46244792222f6c85b11606933af171de root
master 6bc56c1f46244792222f6c85b11606933af171de...132da6064f5d3453d445fd7cb452b148705bdc1b root
master 132da6064f5d3453d445fd7cb452b148705bdc1b...a62e1e693150a2e46ace0ce696cd4a52856dfa65 root
master 58b07b719a4b0039fec810efa52f479ba1b84756...f05321a5b5728bd8a89b7bf530aa44043c951dce root
master f05321a5b5728bd8a89b7bf530aa44043c951dce...7d02e575fd790e76a3284ee435368279a5eb3773 root
GitLab provides an option to restrict a list of allowed SSH keys.
If your SSH key is not on the allowed list, you might encounter an error like
The repository rejected the provided credentials.
To resolve this issue, create a new SSH key pair that meets the guidelines for supported SSH key types. After you generate a supported SSH key, try cloning the repository again.