• Uncategorized

About linux : Store-GitHub-token-in-a-shell-variable-Linux-Debian

Question Detail

I am a new programmer, and also still a “noob” using Debian based distributions and Linux in general. Every time I push to my GitHub repository as u know, I have to write username and password which is my GitHub token, I have the token stored in a file and I have to enter the file copy the token and use it, and it’s a bit annoying, I know it’s possible to store commands in variables to make shell use faster, is there some sort of way to do the same with my token? or which would be a good practice to do so?

Thanks in advance for your time.

Question Answer

You can cache your username/password with this command:

git config --global credential.helper 'cache --timeout=secs'

where secs (seconds) defaults to 900 (15 minutes).

I would suggest using SSH keys which you can find more information about here. When authenticating using SSH keys you don’t have to type in your password manually.

A few things that would change would be that you should select the SSH option instead when you’re going to clone your repository.

I believe the following command can change this configuration for repos that you’ve already cloned using HTTPS:

git remote set-url origin [email protected]:<username>/<repository-name>

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.