Matias Angeluk
Matias Angeluk

Reputation: 77

How to tag a single file? or How do I download a specific file? - GIT

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?

Upvotes: 3

Views: 5731

Answers (3)

VonC
VonC

Reputation: 1328282

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

Upvotes: 1

AnimiVulpis
AnimiVulpis

Reputation: 2726

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

Upvotes: 2

rollstuhlfahrer
rollstuhlfahrer

Reputation: 4078

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.

Upvotes: 2

Related Questions