How to tag a single file? or How do I download a s

2019-05-11 00:20发布

I would like to add a tag to a file to easily download that file and not the entire branch.

How do I download a specific file in GIT?

标签: git gitlab
3条回答
劫难
2楼-- · 2019-05-11 01:02

I am not aware of any way to tag specific files in git.


For the second question: How do I download a specific file in git?

The following works only if you mean "download while in a git repository" (That's how I understand your question, if you mean with git without having the repository see Get a single file from a remote git repository or Not able to extract single file from remote git server )

$ git checkout tagged-commit -- path/to/file.example

Where tagged-commit can be a lot of things, among others:

  • A commit hash
  • A git tag
  • A branch name
  • For more ways see gitrevisions
查看更多
做个烂人
3楼-- · 2019-05-11 01:07

For GitLab specifically, downloading a single file is now explicitly supported, since GitLab 11.2 (August 22nd, 2018), thank to Kia Mei Somabes .

See "Download individual repository files":

When browsing through a project repository on GitLab, the need to download a specific file frequently arises. Until now, this was only possible within the GitLab interface by viewing the file in a new browser tab and then saving it.

GitLab 11.2 introduces a new “Download” button in the file viewer interface, available for each individual repository file, allowing you to download any file directly from the application more easily.

https://about.gitlab.com/images/11_2/download-single-files.png

查看更多
Juvenile、少年°
4楼-- · 2019-05-11 01:16

The way git works is by adding a tag to the entire tree at the state of the commit. There is no way to add a tag to a single file.

Since you are using gitlab, you can just download the file in the right revision from the web interface.

查看更多
登录 后发表回答