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:

  • How can I define an alias for a Git subcommand (e.g. for `list` in `git stash list`)?
  • Is it possible to override git command by git alias?
  • How do I expand a built in Git command with an alias?
  • Git aliases - command line autocompletion of branch names
  • Creating Git alias that gets the last commit
  • Cannot create simple Git alias in MinGW32 on windows 7
  • 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.

  • Lock the Git branch
  • Changing the name of the committer in Xcode
  • git library for Go
  • Merge two separate SVN repositories into a single Git repository
  • git alias for shell command to cd into git root not working as expected
  • git rebase from a url/path
  • 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.