Project

General

Profile

GitCredentials » History » Version 1

Tech-X Corporation, 06/27/2019 05:17 PM

1 1 Tech-X Corporation
# Git Credentials
2
3
Private git repos require a username and password to clone and to push.
4
5
In the near future, bilder may require access to private git repos.  
6
7
This document details how to cache your git credential so that you do not have to enter them interactively.  If you do not cache git credentials in advance of using bilder, bilder will fail to clone required git repositories.
8
9
## ~/.git-credentials on Windows, Linux and Mac
10
  
11
The location of your credentials is the same for Windows, Linux and Mac.  It is the file ~/.git-credentials.  ~ is your login or home directory.  bilder will check for the existence of this file.
12
13
On all of the above platforms where you expect to run bilder, create the file ~/.git-credentials with one line for each server:
14
15
<pre>
16
https://username:password@server.com
17
</pre>
18
19
For ice.txcorp.com, where Tech-X git repos will be stored:
20
21
<pre>
22
https://username:password@ice.txcorp.com
23
</pre>
24
25
If you have a github.com account, you may cache your github.com credentials in the same file:
26
27
<pre>
28
https://username:password@ice.txcorp.com
29
https://github_username:github_password@github.com
30
</pre>
31
32
Because this is a plain text file containing your password(s), change permissions of the file so only you can read it:
33
34
<pre>
35
chmod 600 ~/.git-credentials
36
</pre>
37
38
##  Configure git to check ~/.git-credentials
39
40
git may be configured to check ~/.git-credentials for all repos (--global), or for a single git repo.
41
42
To configure git globally, execute the following command in a 
43
 * Windows - cygwin window
44
 * Linux - terminal
45
 * Mac - terminal
46
47
<pre>
48
git config --global credential.helper 'store --file=~/.git-credentials'
49
</pre>
50
51
This command adds lines to ~/.gitconfig:
52
53
<pre>
54
[credential]
55
        helper = store --file=~/.git-credentials
56
</pre>
57
58
##  Configure git to check ~/.git-credentials for a specific clone or master
59
60
cd to the clone and execute
61
62
<pre>
63
git config credential.helper 'store --file=~/.git-credentials'
64
</pre>
65
66
This command modifies the file:
67
68
<pre>
69
{clone}/.git/config
70
</pre>
71
72
## Mac Keychain
73
74
The default credential.helper for Mac OS X is Keychain application.  git refers to this as *osxkeychain*.
75
76
If you are using bilder on a Mac, git will check for credentials in *osxkeychain*.
77
78
If you have additionally configured git to check ~/.git-credentials, it will check for the server credentials in that file.
79
80
## Checking for server credentials in Keychain
81
82
You may check on the command line for the existence of a stored credential in Keychain:
83
84
<pre>
85
security find-internet-password -s github.com
86
</pre>
87
88
The result of this command will be
89
 * 0 - server credential found in keychain
90
 * 44 - server credential not found in keychain