您可以克隆GitLab片段吗? [英] Can you clone GitLab snippets?
问题描述
创建它们很容易,但是我找不到如何克隆它们并进行脱机编辑的方法.
It's easy enough to create them, but I can't find out how to clone them and edit offline.
有可能吗?
推荐答案
摘要对于共享可能不属于主项目代码库的少量代码和文本很有用.
Snippets are useful for sharing small bits of code and text that may not belong in the main project’s codebase. 这些项目对于依赖它们执行其他任务的组和用户很重要,例如脚本可帮助生成诊断输出或为测试和演示环境设置支持服务. These items are important to groups and users who rely on them for other tasks, like scripts to help generate diagnostic output or setup supporting services for testing and demo environments. 不幸的是,由于缺乏版本控制,因此很难知道摘要是否是最新版本,或者可能发生了什么更改以及如何协调这些更改. Unfortunately, a lack of version control has made it hard to know if a snippet was the latest version or what changes may have happened and how to reconcile those. GitLab中的代码段现在由Git存储库进行版本控制. 在编辑代码段时,每次更改都会创建一个提交.还可以克隆代码片段以在本地进行编辑,然后将其推送回代码段存储库. When editing a Snippet, each change creates a commit. Snippets can also be cloned to make edits locally, and then pushed back to the Snippet repository. 这是在片段上实现更多协作的第一步. This is the first step in enabling more collaboration on Snippets. And with GitLab 13.5 (October 2020): 工程师经常使用代码片段来共享代码,可重用组件,日志和其他项目的示例.这些有价值的信息通常需要其他上下文,并且可能需要多个文件.共享指向多个文件或多个片段的链接使用户很难将这种上下文拼凑在一起并理解所呈现内容的范围. Engineers often use Snippets to share examples of code, reusable components, logs, and other items. These valuable pieces of information often require additional context and may require more than one file. Sharing a link to multiple files or multiple Snippets makes it challenging for users to piece this context together and understand the scope of what is being presented. 在GitLab 13.0中,我们通过为片段提供版本控制基于Git存储库的支持.在查看代码并了解其目的时,版本控制及其提供的历史记录是重要的上下文,但可能还不是全部. In GitLab 13.0, we laid a foundation for Snippets by giving them version control support based on a Git repository. Version control and the history it provides are an important piece of context when looking at code and understanding its purpose, but it may not be everything. GitLab现在在单个代码段中支持多个文件,因此您可以创建由多个部分组成的代码段.它将其用途扩展到无穷的可能性.例如: GitLab now supports multiple files inside of a single Snippet, so you can create Snippets composed of multiple parts. It broadens its use to endless possibilities. For example: 在单个代码段中提供所有这些文件,为可以共享的内容类型以及查看它们时提供的上下文提供了更多选项.我们很高兴看到您使用包含多个文件的代码段创建和共享的内容类型! Providing all of these files in a single Snippet gives more options for the types of content that can be shared and the context that is provided when looking at them. We’re excited to see the types of content you will create and share using Snippets with multiple files!
2015年:原始答案:不直接.
2015: original answer: Not directly. Gitlab在每个项目下都已经有摘录部分. Gitlab already have snippets section under each project. 但是它不可用于克隆. 要求为GitLab提供类似GitHub Gist的功能(基于在 Gistie 上),也在 There was a request for a GitHub Gist-like feature for GitLab (based on Gistie), also asked in GitLab suggestions. 更新2019年,作为评论由 eli ,并记录在"下载代码段" (GitLab 10.8 +) Update 2019, as commented by eli, and documented in "Downloading snippets" (GitLab 10.8+) 目前,仅可以下载代码段,例如 For now its just possible to download snippets, e.g.
这篇关于您可以克隆GitLab片段吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!版本摘要
Versioned Snippets
在以后的版本中,我们将引入对多个文件的支持,继续扩展功能并扩展权限.
In future releases we’ll introduce support for multiple files, continue to expand features and expand permissions.
包含多个文件的代码段
Snippets with multiple files
docker-compose.yml
文件及其关联的.env
文件的代码段.gulpfile.js
文件和一个package.json
文件,它们一起用于引导项目并管理其依赖项.
docker-compose.yml
file and its associated .env
file.gulpfile.js
file coupled with a package.json
file, which together are used to bootstrap the project and manage its dependencies.
像:http://gitabhq.com/project-name/snippets/
Like: http://gitabhq.com/project-name/snippets/
But that was not implemented at the time.
https://gitlab.com/snippets/SNIPPET_ID/raw?line_ending=raw –