Generate SSH Key if you don’t have one
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"Copy the SSH Key to your clipboard
pbcopy < ~/.ssh/id_rsa.pubAdd the SSH Key to your GitHub account
- Go to your GitHub account
- Click on your profile picture
- Click on settings
- Click on SSH and GPG keys
- Click on New SSH Key
- Paste the SSH Key
- Click on Add SSH Key
Test the SSH Key
ssh -T git@github.comHTTPS access
Create a Personal Access Token
- Go to your GitHub account
- Click on your profile picture
- Click on settings
- Click on Developer settings
- Click on Personal access tokens
- Click on Generate new token
- Add a note
- Select the scopes
- Click on Generate token
- Copy the token
Setup git to use the Personal Access Token
git config --global credential.helper storeSetup GOPRIVATE
go env -w GOPRIVATE=github.com/your_username/*Go get the private repo
go get -u github.com/your_username/your_repoAlternatice : Create a .netrc file in your home directory
machine github.com
login your_username
password your_tokenUse the following command to create the file
echo -e "machine github.com\nlogin your_username\npassword your_token" > ~/.netrcTest the setup
go get -u github.com/your_username/your_repoIf using .netrc use the following command to get the private repo
go get git@github.com:your-username/your-private-repo.git
Why always me?