dev-resources.site
for different kinds of informations.
Github or Gitlab | Setup personal token to use automatically in git commands
I came across this trick which works for me pretty well. Our internal soure code repository migrated to gitlab from bitbucket. It was bit annoying to put username and personal token eveytime.
When I googled few times. I fould this trick and thought of sharing with the community.May be someone could get a help from this. There is another method as well. I have tried and tested only the first method. You could try out other method if you would like more secure way to keep your github personal token.
Method 01: Use ~/.netrc file
Step1: Open this ~/.netrc file
vim ~/.netrc
Step2: Addn following entry
cat ~/.netrc
machine github.com login <login-id> password <token-password> <-- sample entry
cat ~/.netrc
machine gitlab.wyoc.com login nuwana1 password sdp-A <-- actual entry
Method-02: Use credentials caching
Run below command in order
git config credential.helper store <-- This will ask your username and passwords and then remember it for future use.
git pull <--Please note running above commands will create a file at ~/.git-credentials and store the credentials in plain text which can be a security risk.
Note: An alternative is to store the credentials in memory rather than the disk. To do this you can run the below command.
git config credential.helper 'cache --timeout=3600'
Featured ones: