开发者

git: getting current revision only

I'm setting up a script that downloads application source code from remote git repository and then launches the application build process. For obvious reas开发者_高级运维ons I only need the current state (revision) of codebase to be downloaded - no need for history. Is there a way in git to achieve that? Cloning the whole repository is too painful.


You can use git clone --depth 1 ... (see FAQ: How do I do a quick clone without history revisions?)


You may try the --depth=1 parameter of git checkout:

git clone --depth=1 git://somehost/somerepo.git

alternatively, if your remote host support, you can use git archive:

 git archive --format=tar --remote=git://somehost/somerepo.git master  | tar -xf -


Setting up a script implies you are going to be building from the same repository repeatedly. If that's the case, doing a git clone with full history is still beneficial, because it only needs to be done once. After that, having the local history will speed up your checkouts considerably even over using git clone --depth=1, because you only download the changes. git clean will do the job if you need to get back to a pristine state for building.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜