Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么`git checkout-`在Makefile中的工作方式不同?_Git_Makefile - Fatal编程技术网

为什么`git checkout-`在Makefile中的工作方式不同?

为什么`git checkout-`在Makefile中的工作方式不同?,git,makefile,Git,Makefile,我的Makefile中有一个非常漂亮的目标,它在bash中工作时没有问题git checkout-应该签出以前的分支,但它没有签出,它停留在开发分支中,就这样,在bash中执行这个分支时,它工作得很好。我是否有不好的if语句?在Makefile中,您需要使用双美元符号才能使用bash子命令,对吗 SHELL := /bin/bash rebase: git stash git checkout develop git pull --rebase origin de

我的Makefile中有一个非常漂亮的目标,它在bash中工作时没有问题
git checkout-
应该签出以前的分支,但它没有签出,它停留在开发分支中,就这样,在bash中执行这个分支时,它工作得很好。我是否有不好的if语句?在Makefile中,您需要使用双美元符号才能使用bash子命令,对吗

SHELL := /bin/bash

rebase:
     git stash
     git checkout develop
     git pull --rebase origin develop
     if [ $$(git status --porcelain | wc -l) -lt 1 ]; then \
         git checkout -;\
         git rebase develop;\
         git stash apply;\
     fi;

如果“
-
”被曲解了,请尝试另一种语法
@{-1}

两者都是。

这似乎是正确的。

您可以在if块中添加一些echo来排除shell逻辑问题。您是对的-这是一个没有添加到任何位置的文件,而且它是未跟踪的文件,因此我添加了
git stash——包括未跟踪的
注意:
git config pull.rebase true;git config rebase.autoStash true在这里可能很有趣:不需要隐藏:不确定我是否正确解释了最后一部分,但是
if/then/fi
语法与
GNU make
无关,它是shell语法。@Tim是的,我指的是“该Makefile中使用的shell语法”。我已经编辑了答案。