Project

General

Profile

Actions

Git Credentials

Private git repos require a username and password to clone and to push.

In the near future, bilder may require access to private git repos.

This document details how to cache your git credential so that you do not have to enter them interactively, and so that bilder will not fail to clone required git repositores.

You should store your git credentials as soon as possible on all machines where you expect to run bilder.

Login directory

~ refers to the login, or home, directory. In some cases, git does not expand ~, and therefore will request interactive entry of credentials. For this reason, these instructions use the explicit home directory instead of ~. Git documentation does refer to ~, but this does not work for accessing github.com credentials.

Windows

Open a Cygwin terminal. To find your login directory, enter

pwd

Your login directory should be /winsame/{username}.

Create the file /winsame/{username}/.git-credentials containing line(s) of the form:

https://username:password@server.com

For ice.txcorp.com, where Tech-X git repos will be stored, the line will be:

https://username:password@ice.txcorp.com

If you have a github.com account, you may cache your github.com credentials in the same file:

https://username:password@ice.txcorp.com
https://github_username:github_password@github.com

Because this is a plain text file containing your password(s), change permissions of the file so only you can read it:

chmod 600 ~/.git-credentials

Configure git to use .git-credentials

git may be configured to check .git-credentials for all repos (--global), or for a single git repo.

To configure for global access, use the command:

git config --global credential.helper 'store --file=/winsame/{username}/.git-credentials'

This command adds lines to /winsame/{username}/.gitconfig:

[credential]
helper = store --file=/winsame/{username}/.git-credentials

To configure git to check .git-credentials for a specific clone or master

cd to the clone and execute

git config credential.helper 'store --file=/winsame/{username}/.git-credentials'

This command modifies the file /winsame/{username}/.git-credentials:

{clone}/.git/config

Linux

Open a terminal. To find your login directory, enter

pwd

Your login directory should be /home/research/{username}. If it is different, note the login directory and modify the instructions below to create .git-credentials

Create the file /home/research/{username}/.git-credentials containing line(s) of the form:

https://username:password@server.com

For ice.txcorp.com, where Tech-X git repos will be stored:

https://username:password@ice.txcorp.com

If you have a github.com account, you may cache your github.com credentials in the same file:

https://username:password@ice.txcorp.com
https://github_username:github_password@github.com

Because this is a plain text file containing your password(s), change permissions of the file so only you can read it:

chmod 600 ~/.git-credentials

Configure git to use .git-credentials

git may be configured to check ~/.git-credentials for all repos (--global), or for a single git repo.

To configure for global access, use the command:

git config --global credential.helper 'store --file=/home/research/{username}/.git-credentials'

This command adds lines to /home/research/{username}/.gitconfig:

[credential]
helper = store --file=/home/research/{username}/.git-credentials

To configure git to check .git-credentials for a specific clone or master

cd to the clone and execute

git config credential.helper 'store --file=/home/research/{username}/.git-credentials'

This command modifies the file:

{clone}/.git/config

Mac

Open a terminal. To find your login directory, enter

pwd

Your login directory should be /home/research/{username}. If it is different, note the login directory and modify the instructions below to create .git-credentials

Create the file /home/research/{username}/.git-credentials containing line(s) of the form:

https://username:password@server.com

For ice.txcorp.com, where Tech-X git repos will be stored:

https://username:password@ice.txcorp.com

If you have a github.com account, you may cache your github.com credentials in the same file:

https://username:password@ice.txcorp.com
https://github_username:github_password@github.com

Because this is a plain text file containing your password(s), change permissions of the file so only you can read it:

chmod 600 ~/.git-credentials

Configure git to use .git-credentials

git may be configured to check ~/.git-credentials for all repos (--global), or for a single git repo.

To configure for global access, use the command:

git config --global credential.helper 'store --file=/home/research/{username}/.git-credentials'

This command adds lines to /home/research/{username}/.gitconfig:

[credential]
helper = store --file=/home/research/{username}/.git-credentials

To configure git to check .git-credentials for a specific clone or master

cd to the clone and execute

git config credential.helper 'store --file=/winsame/{username}/.git-credentials'

This command modifies the file:

{clone}/.git/config

Mac Keychain

The default credential.helper for Mac OS X is Keychain application. git refers to this as osxkeychain.

If you are using bilder on a Mac, git will check for credentials in osxkeychain.

If you have additionally configured git to check ~/.git-credentials, it will check for the server credentials in that file.

When git first uses the credentials in ~/.git-credentials, it will automatically create a Keychain internet password entry using the credentials in ~/.git-credentials.

Checking for server credentials in Keychain

You may check on the command line for the existence of a stored credential in Keychain:

security find-internet-password -s github.com

The result of this command will be

  • 0 - server credential found in keychain
  • 44 - server credential not found in keychain

Verification

To check that your configuration works, enter

git clone https://ice.txcorp.com/gitrepos/code/netcdfc netcdfc

This is a test git repo.

If you have any issues cloning the repo, email sysadmin@txcorp.com.

Updated by Tech-X Corporation over 5 years ago ยท 5 revisions