How do I avoid typing “git” at the begining of every Git command?

后端 未结 15 791
醉酒成梦
醉酒成梦 2021-01-29 22:31

I\'m wondering if there\'s a way to avoid having to type the word git at the beginning of every Git command.

It would be nice if there was a way to use the

15条回答
  •  广开言路
    2021-01-29 22:50

    After

    while read -erp "*git*${PS1@P}" cmd rest; do 
            if _=`git help $cmd 2>&-`
                    then eval git $cmd "$rest"
                    else eval $cmd "$rest"
            fi
    done
    

    every command we type is by default interpreted as a Git command

    if it looks like one, otherwise it'll be interpreted as-is, so you can intermix git with other commands, and if you want to use a punned command just prefix it with a backslash, rm foo would be eval'd as git rm foo, but \rm foo would run the plain rm command. ^d out as usual to end it.

提交回复
热议问题