#git #fabric
#git #fabric
Вопрос:
Я использую 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:
Один из способов — использовать параметры пути с помощью git. Параметры проверяются с помощью git версии 1.7.9.5.
local('git --git-dir ' branch_name '/.git --work-tree ' branch_name ' checkout HEAD -b ' branch_name)