尝试使用fabric来检查git存储库到子目录

时间:2014-06-19 02:33:37

标签: git fabric

我使用fabric来自动创建分支。我的问题是在调用函数之前我不知道分支名称,而且结构不能用于cd。

如何告诉git目标目录将降低一级?

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.

1 个答案:

答案 0 :(得分:0)

一种方法是使用git的路径参数。使用git版本1.7.9.5验证参数。

local('git --git-dir ' + branch_name + '/.git --work-tree ' + branch_name + ' checkout HEAD -b ' + branch_name)