开发者

How to checkout a single file in GIT

We have developed an auto deployment tool for deploying files(ear,war and jar) in jboss server. Developers will check-in files in Visual Source safe. The auto deployment tool automatically checkouts latest files one by one specified by developer and deploys it in jboss server by using API. Now we are moving to GIT to maintain开发者_运维技巧 our source and other deployment files.

Does git have an option to check a single file and paths like VSS?


You can use this

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

This will retrieve the file from the other branch, to current


You can retrieve a specific file from a Git repository. Something like:

git show HEAD:filename.txt

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

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

I've shown redirecting the output to a file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜