你能克隆 GitLab 片段吗? [英] Can you clone GitLab snippets?

查看:18
本文介绍了你能克隆 GitLab 片段吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建它们很容易,但我不知道如何克隆它们并离线编辑.

有可能吗?

解决方案

<块引用>

编辑片段时,每次更改都会创建一次提交.也可以克隆片段以在本地进行编辑,然后将其推送回片段存储库.

这是在 Snippets 上实现更多协作的第一步.
在未来的版本中,我们将引入对多个文件的支持,继续扩展功能并扩展权限.

参见

参见文档问题.


2015:原始答案:不直接.

Gitlab 已经在每个项目下都有片段部分.
喜欢:http://gitabhq.com/project-name/snippets/

但它不能用于克隆.

请求为 GitLab 提供类似 GitHub Gist 的功能(基于在 Gistie),也在 GitLab 建议.
但当时并没有实施.


2019 年更新,由 评论a href="https://stackoverflow.com/users/4940240/eli">eli,并记录在 "下载片段"(GitLab 10.8+)

<块引用>

目前只能下载片段,例如

https://gitlab.com/snippets/SNIPPET_ID/raw?line_ending=raw –

It's easy enough to create them, but I can't find out how to clone them and edit offline.

Is it possible?

解决方案

May 2020, for GitLab 13.0: yes!

Versioned Snippets

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.

Snippets in GitLab are now version controlled by a Git repository.

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.
In future releases we’ll introduce support for multiple files, continue to expand features and expand permissions.

See documentation and issue.


And with GitLab 13.5 (October 2020):

Snippets with multiple files

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.

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 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:

  • A snippet that includes a script and its output.
  • A snippet that includes HTML, CSS, and JS code, from which the result can be easily previewed.
  • A snippet with a docker-compose.yml file and its associated .env file.
  • A gulpfile.js file coupled with a package.json file, which together are used to bootstrap the project and manage its dependencies.

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!

See Documentation and Issue.


2015: original answer: Not directly.

Gitlab already have snippets section under each project.
Like: http://gitabhq.com/project-name/snippets/

But it is not available for cloning.

There was a request for a GitHub Gist-like feature for GitLab (based on Gistie), also asked in GitLab suggestions.
But that was not implemented at the time.


Update 2019, as commented by eli, and documented in "Downloading snippets" (GitLab 10.8+)

For now its just possible to download snippets, e.g.

https://gitlab.com/snippets/SNIPPET_ID/raw?line_ending=raw – 

这篇关于你能克隆 GitLab 片段吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆