How to override Git config options by command line parameters?

I want to override certain Git config options (in my case http.proxy) when calling a Git command directly by using command line parameters. Is this possible?

  • How do I configure Git to automatically pull from current branch when using “git pull”?
  • Where does git config --global get written to?
  • How to make git diff --ignore-space-change the default
  • git merge strategy for static config file in each branch
  • What should I do about user-specific config files (example: .idea/)?
  • How to configure kdiff3 instead of emerge as a git mergetool?
  • Getting fatal: object is corrupted when pushing to a remote repo
  • How to delete a file in remote repository ONLY?
  • Is there a way to get the affected files of a commit with a git post-commit hook?
  • How to merge a specific commit in Git
  • Using git below web root in production
  • git pull - will it fetch tags on remote by default?
  • 2 Solutions collect form web for “How to override Git config options by command line parameters?”

    Yes, you can pass it with -c, like:

    git -c http.proxy=someproxy clone https://github.com/user/repo.git
    

    Note that there is a new feature regarding the ability to override (with the command git -c) a config:

    You couldn’t set a config to an empty string (git -c http.proxy= or any other foo.bar=), that is until git 2.1.2 (Sept 30th, 2014), and commit a789ca7 Junio C Hamano (gitster)

    config: teach “git -c” to recognize an empty string

    In a config file, you can do:

    [foo]
    bar
    

    to turn the “foo.bar” boolean flag on, and you can do:

    [foo]
    bar=
    

    to set “foo.bar” to the empty string.
    However, git’s “-c” parameter treats both:

    git -c foo.bar
    

    and

    git -c foo.bar=
    

    as the boolean flag, and there is no way to set a variable to the empty string.
    This patch enables the latter form to do that.

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