如何在GIT中签出单个文件 [英] How to checkout a single file in GIT

查看:113
本文介绍了如何在GIT中签出单个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们开发了一个用于在jboss服务器中部署文件(ear,war和jar)的自动部署工具。开发人员将在Visual Source安全中签入文件。自动部署工具自动检出开发人员指定的最新文件,并使用API​​将其部署到jboss服务器中。现在我们正在转向GIT来维护我们的源代码和其他部署文件。

git是否有选项来检查单个文件和路径(如VSS)?

解决方案

您可以从Git存储库中检索特定文件。例如:

  git show HEAD:filename.txt 

如果您的存储库位于另一个目录中,您可以使用 GIT_DIR

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

我已经显示将输出重定向到一个文件。


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

这篇关于如何在GIT中签出单个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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