Project

General

Profile

GitCredentials » History » Version 2

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