How to enter command with password for git pull?

I want to do this command in one line: git pull && [my passphrase]

How to do it?

  • How do I use Notepad++ Compare as the diff tool in git bash/command line?
  • Git diff - ignore reorder
  • “${1-}” vs “$1”
  • Git cloning: remote end hung up unexpectedly, tried changing postBuffer but still failing
  • Is it possible to remove a remote repository on Github through the command line?
  • Cygwin gitk issue
  • How to start git daemon on Windows
  • Git daemon cloning error
  • Gitolite permissions on branches
  • “Will not add file alias 'samefile' ('SameFile' already exists in index)” when `git add` operation
  • filtered version of git repository
  • how to import Git project to TFS Cloud
  • 4 Solutions collect form web for “How to enter command with password for git pull?”

    This is not exactly what you asked for, but for http(s):

    • you can put the password in .netrc file (_netrc on windows). From there it would be picked up automatically. It would go to your home folder with 600 permissions.
    • you could also just clone the repo with https://user:pass@domain/repo but that’s not really recommended as it would show your user/pass in a lot of places…
    • a new option is to use the credential helper. Note that credentials would be stored in clear text in your local config using standard credential helper. credential-helper with wincred can be also used on windows.

    Usage examples for credential helper

    • git config credential.helper store – stores the credentials indefinitely.
    • git config credential.helper 'cache --timeout=3600'– stores for 60 minutes

    For ssh-based access, you’d use ssh agent that will provide the ssh key when needed. This would require generating keys on your computer, storing the public key on the remote server and adding the private key to relevant keystore.

    I found one way to supply credentials for a https connection on the command line. You just need to specify the complete URL to git pull and include the credentials there:

    git pull

    You do not need to have the repository cloned with the credentials before, this means your credentials don’t end up in .git/config. (But make sure your shell doesn’t betray you and stores the command line in a history file.)

    Doesn’t answer the question directly, but I found this question when searching for a way to, basically, not re-enter the password every single time I pull on a remote server.

    Well, git allows you to cache your credentials for a finite amount of time. It’s customizable in git config and this page explains it very well:

    In a terminal, run:

    $ git config --global credential.helper cache
    # Set git to use the credential memory cache

    To customize the cache timeout, you can do:

    $ git config --global credential.helper 'cache --timeout=3600'
    # Set the cache to timeout after 1 hour (setting is in seconds)

    Your credentials will then be stored in-memory for the requested amount of time.

    Note that the way the git credential helper “store” will store the unencrypted passwords changes with Git 2.5+ (Q2 2014).
    See commit 17c7f4d by Junio C Hamano (gitster)


    Tweak the sample “store” backend of the credential helper to honor XDG configuration file locations when specified.

    The doc now say:

    If not specified:

    • credentials will be searched for from ~/.git-credentials and $XDG_CONFIG_HOME/git/credentials, and
    • credentials will be written to ~/.git-credentials if it exists, or $XDG_CONFIG_HOME/git/credentials if it exists and the former does not.
    Git Baby is a git and github fan, let's start git clone.