Skip to content

Dear Internet Explorer user: Your browser is no longer supported

Please switch to a modern browser such as Microsoft Edge, Mozilla Firefox or Google Chrome to view this website's content.

Stop Git from always asking for user credentials

Here are a few methods for preventing Git from asking for user credentials upon every push.

When working on the command-line and making regular pushes to GitHub, it becomes annoying to have to re-enter one’s credentials on every push. Thankfully there are several ways to prevent this from happening:

Option 1: Make Git store the username and password

You can tell Git to store the credentials, which will prevent them being requested over and over again:

git config --global credential.helper store

Option 2: Make Git cache the username and password

You can tell Git to cache your credentials for the current session:

git config --global credential.helper cache

If you want to apply a time limit for this, use the following code where the units are in seconds:

git config –global credential.helper 'cache –timeout=3600'

Option 3: Move to SSH

You can update the URL of origin remote using SSH instead of HTTPS. This protocol is often more secure and efficient, but can be quite a hassle to get working. SSH may also be blocked by corporate firewalls in some circumstances.

git remote set-url origin


No comments have yet been submitted. Be the first!

Have Your Say

The following HTML is permitted:
<a href="" title=""> <b> <blockquote cite=""> <code> <em> <i> <q cite=""> <strike> <strong>

Comments will be published subject to the Editorial Policy.