尝试使用Fabric将git存储库检出到子目录 [英] Trying to use fabric to check out a git repository to a subdirectory
本文介绍了尝试使用Fabric将git存储库检出到子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Fabric来自动创建分支.我的问题是在调用函数之前我不知道分支名称,并且fabric无法与cd一起使用.
I'm using fabric to automate branch creation. My problem is I don't know the branch name before the function is called, and fabric doesn't work with cd.
如何告诉git目标目录要低一级?
How can I tell git that the target directory is going to be one level lower?
Fabfile:
def new_branch(branch_name):
local('mkdir ' + branch_name)
local('git clone /var/www/finance ' + branch_name)
local('git checkout HEAD ./' + branch_name + ' -b ' + branch_name)
我得到的输出是:
[localhost] local: mkdir test
[localhost] local: git clone /var/www/finance test
Cloning into 'test'...
done.
[localhost] local: git checkout HEAD ./test -b test
fatal: Not a git repository (or any of the parent directories): .git
Fatal error: local() encountered an error (return code 128) while executing 'git checkout HEAD ./test -b test'
Aborting.
推荐答案
一种方法是在git中使用路径参数.使用git版本1.7.9.5验证参数.
One way is to use path parameters with git. Parameters are verified with git version 1.7.9.5.
local('git --git-dir ' + branch_name + '/.git --work-tree ' + branch_name + ' checkout HEAD -b ' + branch_name)
这篇关于尝试使用Fabric将git存储库检出到子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文