Я установил репозиторий git origin с именем project_name / .git.
ssh to the server, (entering ssh passwords or passphrases as I go)
mkdir project_name
cd project_name
git init
touch fabfile.py
git add fabfile.py
git commit -a -m "almost empty"
git checkout -b web
Я оставляю сеть филиалов проверенной.Вернуться на локальный компьютер.
Я извлекаю данные с сервера через клон и добавляю содержимое моего каталога проекта в мастер-ветку локального репо.Я не использую fabric, а просто настраиваю вещи, хотя, я полагаю, эти шаги тоже можно автоматизировать, и ни один из них не нуждается в другой парольной фразе ssh.
cd /path/to/project_name/..
git clone ssh://joe@some_server.com/var/web/project_name/.git
cd project_name
gvim fabfile.py
git add fabfile.py
git commit -a -m "fabfile edits"
Теперь я начинаю использовать fabric.Ниже приводится выдержка из моего fabfile для управления тегами и ветвями git:
#Usage: fab committag brpush | fab committag push | fab push | fab tag
def committag():
"""commit chgs, tag new commit, push tags to server."""
prompt('commit descr: ', 'COM_MSG', default='new stuff')
prompt('commit name: ', 'COM_NAME', default='0.0.1')
local('git commit -a -m "%(COM_MSG)s"' % env)
local('sleep 1')
local('git tag -u "John Griessen" -m "%(COM_MSG)s" %(COM_NAME)s' % env)
local('sleep 1')
local('git push origin --tags') #pushes local tags
def brpush():
"""create a new branch, default COM_NAME, then push to server."""
prompt('new branch name: ', 'BR_NAME', default= '%(COM_NAME)s' % env)
local('git checkout -b %(BR_NAME)s' % env)
local('sleep 2')
local('git checkout master')
local('git push origin --tags') #pushes local tags
local('git push --all origin') #pushes local master and branches
def push():
"""Push existing tags and changes to server."""
local('git push origin --tags') #pushes local tags
local('git push --all origin') #pushes local master and branches
def tag(): #Call this from committag()
"""create a gpg signed tag on the local git repo tag from prompted name ."""
prompt('tag descr: ', 'TAG_MSG', default='0.0.1')
prompt('tag name: ', 'TAG_NAME', default='0.0.1')
local('git tag -u "John Griessen" -m "%(TAG_MSG)s" %(TAG_NAME)s' % env)
Чтобы использовать вышеупомянутые определения fabfile, я просто делаю некоторые изменения в директории моего проекта, думаю о соответствующем сообщении о них и делаю:
$fab committag
и у меня есть изменения и пометки на сервере.Или:
$fab committag brpush
и у меня создана новая ветка, а сервер обновлен.