3

I have such a beautiful target in my Makefile which works in bash without a problem. git checkout - should checkout a previous branch, but it doesn't, it stays in that develop branch and that's it, while executing this in bash it works well. Do I have bad if statement maybe? In Makefile you need to you double dollar sign in order to have a bash subcommand right?

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; 
3
  • you could add some echo to the if block to rule out shell logic issues Commented Apr 9, 2018 at 4:28
  • You right - it was one file which haven't been added anywhere and it was untraced one, so I've added git stash --include-untracked Commented Apr 9, 2018 at 5:14
  • Note: git config pull.rebase true; git config rebase.autoStash true can be of interest here: no need for stashing: stackoverflow.com/a/30209750/6309 Commented Apr 9, 2018 at 7:39

1 Answer 1

1

If the '-' is somehow misinterpreted, try the alternative syntax @{-1}.

Both are mentioned here.
The if/then shell syntax used in Makefile seems correct.

Sign up to request clarification or add additional context in comments.

2 Comments

Not sure I interpreted the last part correctly but the if/then/fi syntax has nothing to do with GNU make, it's shell syntax.
@Tim Yes, I meant the "shell syntax used in that Makefile". I have edited the answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.