|
1 |
| -[[_rerere]] |
2 |
| -=== Rerere |
| 1 | +=== Other Helpers |
| 2 | + |
| 3 | +[[_credential_caching]] |
| 4 | +==== Credential Helpers |
| 5 | + |
| 6 | +If you don't want to type your username and password on the command line every time you push to an HTTPS Git URL, you can configure Git to pull your credentials from a store of some kind. There are various types of credential helpers available.((credential helpers)) |
| 7 | + |
| 8 | +===== Memory Cache |
| 9 | + |
| 10 | +The stored credentials never touch the disk. |
| 11 | + |
| 12 | + $ git config credential.helper cache |
| 13 | + |
| 14 | +Default is 15 minutes |
| 15 | + |
| 16 | + $ git config credential.helper 'cache --timeout=300' |
| 17 | + |
| 18 | +Timeout is in seconds, so 300 would be 5 minutes. |
| 19 | + |
| 20 | + $ git credential-cache exit |
| 21 | + |
| 22 | +Kills the daemon that stores the credentials early. |
| 23 | + |
| 24 | +===== Simple Disk Store |
| 25 | + |
| 26 | + $ git config credential.helper store |
| 27 | + |
| 28 | +`~/.git-credentials` |
| 29 | + |
| 30 | +The .git-credentials file is stored in plaintext. Each credential is stored on its own line as a URL like: |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | +===== Windows |
| 35 | + |
| 36 | +msysGit should install wincred helper |
| 37 | + |
| 38 | +msysgit.github.io |
| 39 | + |
| 40 | + $ git config --global credential.helper wincred |
| 41 | + |
| 42 | + |
| 43 | +* GitHub for Windows |
| 44 | + |
| 45 | + |
| 46 | +https://gitcredentialstore.codeplex.com/ |
| 47 | + |
| 48 | +[credential] |
| 49 | +helper = !\"C:/Program Files (x86)/GitExtensions/GitCredentialWinStore/git-credential-winstore.exe\" |
| 50 | + |
| 51 | + |
| 52 | +===== Mac Keychain |
| 53 | + |
| 54 | +To use this option, you need to install the `osxkeychain` credential helper and tell Git to use it. If you installed Git using Homebrew, the `osxkeychain` helper may already be installed. |
| 55 | + |
| 56 | +To find out if the `osxkeychain` credential helper is already installed, you can run it directly. If it's installed, you should see something like this: |
| 57 | + |
| 58 | +[source,shell] |
| 59 | +---- |
| 60 | +$ git credential-osxkeychain |
| 61 | +usage: git credential-osxkeychain <get|store|erase> |
| 62 | +---- |
| 63 | + |
| 64 | +If it's not installed, you'll see this: |
| 65 | + |
| 66 | +[source,shell] |
| 67 | +---- |
| 68 | +$ git credential-osxkeychain |
| 69 | +# Test for the cred helper |
| 70 | +# git: 'credential-osxkeychain' is not a git command. See 'git --help'. |
| 71 | +---- |
| 72 | + |
| 73 | +If you do not have the `osxkeychain` helper, you can build it yourself out of the `contrib/` directory of Git. |
| 74 | + |
| 75 | +[source,shell] |
| 76 | +---- |
| 77 | +$ cd git/contrib/credential/osxkeychain |
| 78 | +$ make |
| 79 | +gcc -c -g -O2 -Wall git-credential-osxkeychain.c |
| 80 | +gcc -g -O2 -Wall -o git-credential-osxkeychain git-credential-osxkeychain.o -L/opt/boxen/homebrew/lib -Wl,-framework -Wl,Security |
| 81 | +---- |
| 82 | + |
| 83 | +Now, move the helper into your path somewhere. |
| 84 | + |
| 85 | +[source,shell] |
| 86 | +---- |
| 87 | +sudo mv git-credential-osxkeychain /usr/sbin/ |
| 88 | +---- |
| 89 | + |
| 90 | +Finally, tell Git to use `osxkeychain` using the global `credential.helper` config: |
| 91 | + |
| 92 | +[source,shell] |
| 93 | +---- |
| 94 | +$ git config --global credential.helper osxkeychain |
| 95 | +---- |
| 96 | + |
| 97 | +You can also delete stored credentials either from the Mac Keychain Access app or via the command line with the `erase` command. |
| 98 | + |
| 99 | +[source,shell] |
| 100 | +---- |
| 101 | +$ git credential-osxkeychain erase |
| 102 | +host=github.com |
| 103 | +protocol=https |
| 104 | +---- |
| 105 | + |
| 106 | +===== Gnome Keyring |
| 107 | + |
| 108 | +[source,shell] |
| 109 | +---- |
| 110 | +$ cd /usr/share/git/credential/gnome-keyring |
| 111 | +$ make |
| 112 | +$ git config --global credential.helper /usr/share/git/credential/gnome-keyring/git-credential-gnome-keyring |
| 113 | +
|
| 114 | +$ sudo apt-get install libgnome-keyring-dev |
| 115 | +$ cd /usr/share/doc/git/contrib/credential/gnome-keyring |
| 116 | +$ sudo make |
| 117 | +$ git config --global credential.helper /usr/share/doc/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring |
| 118 | +---- |
| 119 | + |
| 120 | +===== .netrc |
| 121 | + |
| 122 | +That script would allow you to use gpg-encrypted netrc files, avoiding the issue of having your credentials stored in a plain text file. |
| 123 | + |
| 124 | +-f|--file AUTHFILE |
| 125 | +specify netrc-style files. |
| 126 | +Files with the .gpg extension will be decrypted by GPG before parsing. |
| 127 | +Multiple -f arguments are OK. They are processed in order, and the first matching entry found is returned via the credential helper protocol (see below). |
| 128 | + |
| 129 | +When no -f option is given, .authinfo.gpg, .netrc.gpg, .authinfo, and .netrc files in your home directory are used in this order. |
| 130 | + |
| 131 | +To enable this credential helper: |
| 132 | + |
| 133 | + $ git config credential.helper 'netrc -f AUTHFILE1 -f AUTHFILE2' |
| 134 | + |
| 135 | + $ gpg -e -r a_recipient _netrc |
| 136 | + |
| 137 | +You now can delete the _netrc file, keeping only the _netrc.gpg encrypted one |
| 138 | + |
| 139 | +use that encrypted file |
| 140 | + |
| 141 | + $ git config credential.helper "netrc -f C:/path/to/_netrc.gpg -v" |
| 142 | + |
| 143 | +===== Custom Helper |
| 144 | + |
| 145 | + |
| 146 | +==== Rerere |
3 | 147 |
|
4 | 148 | The `git rerere` functionality is a bit of a hidden feature. The name stands for ``reuse recorded resolution'' and as the name implies, it allows you to ask Git to remember how you've resolved a hunk conflict so that the next time it sees the same conflict, Git can automatically resolve it for you.
|
5 | 149 |
|
|
0 commit comments