Domanda

I figured out that git branch | grep <something> | cut -d' ' -f2 will give me the name of a branch that contains the substring <something>. I'm trying to put this command in a git alias, like so:

[alias]
    gb = "!f(){ git branch | grep $1 | cut -d' ' -f2; };f"
    # ...

However, this does not work; it just produces a blank line. How do I fix this?

È stato utile?

Soluzione

As indicated by the commenter above, the fix is to use awk '{print $NF}' instead of the cut command.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top