How to make bash suppose all commands to be git commands?

Can I make bash to suppose the command always to be a git command?

I mean:

If I wrote push origin master then it would execute git push origin master?

Note: I would use it in git bash (Windows environment), so I do not need regular commands (ls, cd, etc.) to work.

  • Delete single file from an old commit
  • Setup Unity Smart Merge
  • git revert in Egit
  • Missing git support, install posh-git with 'Install-Module posh-git' and restart cmder
  • Retrieve commit from a deleted branch in the remote
  • Git with Cygwin - not accepting userinput for Username
  • Git mergetool using Android Studio (IntelliJ)
  • git clone from GitHub RPC failed; result=56, HTTP code
  • 4 Solutions collect form web for “How to make bash suppose all commands to be git commands?”

    You may want to try this small git shell, instead:

    gitsh () {
        while read -r -p "gitsh> " -a GITCOMMAND; do
            git "${GITCOMMAND[@]}"
        done
    }
    

    After that function is defined, run it once, and it will sit in an infinite loop,
    reading a command line and passing it as options to the git command.

    EDIT: Adding the -e option to the read command, as suggested by gniourf_gniourf, gives you a nice Readline-based environment where you can retrieve and edit your history.

    You could add aliases for commonly used commands e.g. push would become git push etc. This solution needs to specify all commands you are using, but should not break anything.

    Assuming “git bash” is like regular bash, use the command_not_found_handle function:

    function command_not_found_handle {
      command git "$0" "$@"
    }
    

    http://www.gnu.org/software/bash/manual/bashref.html#Command-Search-and-Execution

    The possibility for sending git inadvertent commands exists, but that’s what you’re asking for in the question.

    You may add scripts named push, commit etc. to your PATH. This way your shell would have push, commit etc. “commands”. This should work with whatever shell you are using, not only bash.

    Git Baby is a git and github fan, let's start git clone.