1

I'm working on a git alias and have run into syntax issues at its current (incomplete) state:

[alias]
gup2 = !git checkout $1 && BEFORE=$(git stash list) && git stash save gup-temporary-stash && git fetch && git rebase -p origin/$1 && if [ "$BEFORE" != "$(git stash list)" ]; then git stash pop; fi

The problem seems to start when the double quotes are introduced. I've tried many combinations of single quotes and double quotes with escape sequences, but I can't seem to find the right combination.

What is the syntactically correct way to form the above alias?

joelmdev
  • 11,083
  • 10
  • 65
  • 89

2 Answers2

2

After a year of using a Git alias, I decided that they are not worth the trouble. In my mind, the only benefit of using an alias is so you can put

git foo

instead of

git-foo.sh

and in fact if your script is named as my example here, you can even call it as

git foo.sh

or if you name the script git-foo then you can even call it as

git foo

completely eliminating the benefit of git alias in my opinion. Git syntax for scripting is crap compared to just writing an external script, which I have done.

Zombo
  • 1
  • 62
  • 391
  • 407
  • 1
    I like `git s` for git status, I've probably saved about 100 hours of time with that one, but otherwise I agree with you. – usumoio Jul 11 '13 at 15:58
  • I generally agree, but if command is really small, having it fit into your config (where you may share config to multiple machines) can be useful. I like the solution outlined here - http://stackoverflow.com/a/3322412/652904 and I use it to launch external graphical diff tools to diff a single commit `meld1 = "!f() { git difftool -y -t meld $1^ $1; }; f"` – nhed Dec 15 '15 at 00:10
0

You could try either the character code of the character you want, or the hex name of the character you want. Here is a link to these things:

http://www.utf8-chartable.de/

At the core of what you are doing, you are just writing a bash script in your environment. So whatever lets you write quotes outside of git's bash interface should be able to work here.

usumoio
  • 3,500
  • 6
  • 31
  • 57