How to check one file in GIT

We developed an automatic deployment tool for deploying files (ear, war and jar) on jboss server. Developers will check files in Visual Source in safety. The automatic deployment tool automatically checks the latest files one at a time as specified by the developer and deploys it to the jboss server using the API. We are now moving on to GIT to support our source and other deployment files.

Does GIT have the ability to check a single file and paths like VSS?

+5
source share
2 answers

You can get a specific file from the Git repository. Sort of:

git show HEAD:filename.txt 

If your repository is in a different directory, you can use GIT_DIR :

 env GIT_DIR=/path/to/git/repo.git git show HEAD:filename.txt >filename.txt 

I showed output redirection to a file.

+5
source

You can use this

 git checkout <branch-where-the-file-is> -- path/to/file/in/the/other/branch 

This will extract the file from another branch, to the current

+3
source

Source: https://habr.com/ru/post/896854/


All Articles