我有以下配置:
git version 1.8.5.6
GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)
我打电话给zgit_info_update
并试图提交。但是在Travis(https://github.com/travis-ci/travis-ci/issues/6069)中从bash运行git diff --name-only dev
时,我仍遇到问题。
有人可以协助让这个工作吗?
这里输出:
git version 1.8.5.6
GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
* (detached from FETCH_HEAD)
master
remotes/origin/HEAD -> origin/master
remotes/origin/master
[detached HEAD 72afa70] Add package.json
1 file changed, 37 insertions(+)
create mode 100644 package.json
fatal: ambiguous argument 'dev': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
答案 0 :(得分:0)
使用以下命令解决了该问题:
if [ "$TRAVIS" == "true" ]; then
#resolving `detached HEAD` by attaching HEAD to the `TRAVIS_FROM_BRANCH` branch
TRAVIS_FROM_BRANCH="travis_from_branch"
git branch $TRAVIS_FROM_BRANCH
git checkout $TRAVIS_FROM_BRANCH
#fetching `TRAVIS_BRANCH` branch
git fetch origin $TRAVIS_BRANCH
git checkout -qf FETCH_HEAD
git branch $TRAVIS_BRANCH
git checkout $TRAVIS_BRANCH
#switch to `TRAVIS_FROM_BRANCH`
git checkout $TRAVIS_FROM_BRANCH
fi
答案 1 :(得分:0)
更简单的解决方法是
git remote set-branches --add origin $BRANCH_TO_DIFF_AGAINST
git fetch
git diff origin/$BRANCH_TO_DIFF_AGAINST