[英]Capistrano/Git not recognising checkout -B flag unless logged in via ssh
我正在嘗試使用capistrano將wordpress網站部署到我在dreamhost上的帳戶中。
在大多數情況下,capistrano似乎都在工作。 這是cap dev git:check的輸出
$ cap dev git:check
INFO [1cd5c6b7] Running /usr/bin/env mkdir -p /home/parisstilton/tmp/theparisstilton.com/ on theparisstilton.com
DEBUG [1cd5c6b7] Command: /usr/bin/env mkdir -p /home/parisstilton/tmp/theparisstilton.com/
INFO [1cd5c6b7] Finished in 1.895 seconds with exit status 0 (successful).
DEBUG Uploading /home/parisstilton/tmp/theparisstilton.com/git-ssh.sh 0.0%
INFO Uploading /home/parisstilton/tmp/theparisstilton.com/git-ssh.sh 100.0%
INFO [4ede30ed] Running /usr/bin/env chmod +x /home/parisstilton/tmp/theparisstilton.com/git-ssh.sh on theparisstilton.com
DEBUG [4ede30ed] Command: /usr/bin/env chmod +x /home/parisstilton/tmp/theparisstilton.com/git-ssh.sh
INFO [4ede30ed] Finished in 0.317 seconds with exit status 0 (successful).
INFO [8d47d9d7] Running /usr/bin/env mkdir -p /home/parisstilton/tmp/theparisstilton.com/ on theparisstilton.com
DEBUG [8d47d9d7] Command: /usr/bin/env mkdir -p /home/parisstilton/tmp/theparisstilton.com/
INFO [8d47d9d7] Finished in 1.668 seconds with exit status 0 (successful).
DEBUG Uploading /home/parisstilton/tmp/theparisstilton.com/git-ssh.sh 0.0%
INFO Uploading /home/parisstilton/tmp/theparisstilton.com/git-ssh.sh 100.0%
INFO [1aacdb9a] Running /usr/bin/env chmod +x /home/parisstilton/tmp/theparisstilton.com/git-ssh.sh on theparisstilton.com
DEBUG [1aacdb9a] Command: /usr/bin/env chmod +x /home/parisstilton/tmp/theparisstilton.com/git-ssh.sh
INFO [1aacdb9a] Finished in 0.266 seconds with exit status 0 (successful).
DEBUG [bd5cfd74] Running /usr/bin/env git ls-remote git@bitbucket.org:sentur/partisstilton.git on theparisstilton.com
DEBUG [bd5cfd74] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/home/parisstilton/tmp/theparisstilton.com/git-ssh.sh /usr/bin/env git ls-remote git@bitbucket.org:sentur/partisstilton.git )
DEBUG [bd5cfd74] 5cadb90b1a5d4bbe59c2eb8e3f3e108f49b98fd0 HEAD
DEBUG [bd5cfd74] 9451025272b2a594ffc2af259bfce50c66ff15fc refs/heads/dev
DEBUG [bd5cfd74] 5cadb90b1a5d4bbe59c2eb8e3f3e108f49b98fd0 refs/heads/master
DEBUG [bd5cfd74] Finished in 2.722 seconds with exit status 0 (successful).
DEBUG [baacc1b3] Running /usr/bin/env git ls-remote git@bitbucket.org:sentur/partisstilton.git on theparisstilton.com
DEBUG [baacc1b3] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/home/parisstilton/tmp/theparisstilton.com/git-ssh.sh /usr/bin/env git ls-remote git@bitbucket.org:sentur/partisstilton.git )
DEBUG [baacc1b3] 5cadb90b1a5d4bbe59c2eb8e3f3e108f49b98fd0 HEAD
DEBUG [baacc1b3] 9451025272b2a594ffc2af259bfce50c66ff15fc refs/heads/dev
DEBUG [baacc1b3] 5cadb90b1a5d4bbe59c2eb8e3f3e108f49b98fd0 refs/heads/master
DEBUG [baacc1b3] Finished in 2.724 seconds with exit status 0 (successful).
當我使用以下代碼捆綁執行cap cap dev deploy( http://pastebin.com/fCWRjEyv )進行部署時,capistrano在以下位置失敗
DEBUG [e6f95da6] Command: cd /home/parisstilton/dev.theparisstilton.com/repo && ( GIT_ASKPASS=/bin/echo GIT_SSH=/home/parisstilton/tmp/theparisstilton.com/git-ssh.sh /usr/bin/env git checkout -B 20140806215353 origin/dev )
DEBUG [e6f95da6] error: unknown switch `B'
DEBUG [e6f95da6] usage: git checkout [options] <branch>
DEBUG [e6f95da6] or: git checkout [options] [<branch>] -- <file>...
但是,如果我使用ssh進入dreamhost服務器並運行相同的命令,則可以識別git checkout -B標志,效果很好。 我懷疑這可能是因為我在$ PATH中的〜/ packages / bin /中安裝了較新版本的git(2.0.4)。 在Dreamhost上,默認的git是git版本1.7.2.5。
[beehive]$ cd /home/parisstilton/dev.theparisstilton.com/repo && ( GIT_ASKPASS=/bin/echo GIT_SSH=/home/parisstilton/tmp/theparisstilton.com/git-ssh.sh /usr/bin/env git checkout -B 20140806215353 origin/dev )
Branch 20140806215353 set up to track remote branch dev from origin.
Switched to a new branch '20140806215353'
我設法找到一個簡單的解決方案(盡管不確定是否正確,但對我有用)。
編輯〜/ .bashrc文件以更新$ PATH,因為它是由非交互式shell運行的,而我最初更新$ PATH的〜/ .bash_profile是僅由bash在交互式shell登錄時運行的。
所以這是代碼。
$nano ~/.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
#add ~/packages/bin installed apps/git to $PATH
export PATH=~/packages/bin:$PATH
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.