2

I am currently learning the HubFlow way of managing versioning and workflow using Git and GitHub.

I created this dummy repository to get some hands-on experience.

I have tried certain commands like

git hf update

I get prompted for my GitHub credentials multiple times.

Here is an example:

macair:learnhubflow simkimsia$ git hf update
Fetching origin
Already on 'master'
From https://github.com/simkimsia/learnhubflow
 * branch            master     -> FETCH_HEAD
Already up-to-date.
Username: 
Password: 
Everything up-to-date
Switched to branch 'develop'
Your branch is behind 'origin/develop' by 2 commits, and can be fast-forwarded.
From https://github.com/simkimsia/learnhubflow
 * branch            develop    -> FETCH_HEAD
Updating d76bec3..b351907
Fast-forward
 IMG_0001-w800-h600.png |  Bin 0 -> 192787 bytes
 1 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 IMG_0001-w800-h600.png
Username: 
Password: 
Everything up-to-date
Switched to branch 'master'

Summary of actions:
- Changes from origin/master have been pulled into branch 'master'
- Changes from origin/develop have been pulled into branch 'develop'
- You are now on branch 'master'

Is there a way for me to simply supply the GitHub credentials just once each time I used a HubFlow command?

Paul Cezanne
  • 8,629
  • 7
  • 59
  • 90
Kim Stacks
  • 10,202
  • 35
  • 151
  • 282

2 Answers2

1

Use SSH keys+URLs. If you already have an SSH key, add it to your Github account.

If you don't have an SSH key, Github provides a nice guide walking you through creating a keypair and authorizing your public key.

After you've added a public key to Github, you'll need to change your remotes to use the SSH URLs:

https://github.com/simkimsia/learnhubflow -> git@github.com:simkimsia/learnhubflow.git

Assuming that this is your origin, you can make the change with the following command:

git remote set-url origin git@github.com:simkimsia/learnhubflow.git

Now you'll be authenticated using your keypair instead of needing to type in your password. If you wish, you can set a password for your keypair so that someone who walks up to your unlocked computer can't push changes as you.

cjc343
  • 3,735
  • 1
  • 29
  • 34
  • Thank you for your advice. On top of what you suggested, I also had removed all the SSH keys I had previously in GitHub user settings before adding my current one on the machine. Thank you. – Kim Stacks Jan 26 '13 at 07:21
0

Or if it is difficult to maintain SSH Keys for multiple account you can cache password for 15 mins.

$ git config credential.helper cache

With this configuration once, you have to type your password only once and it will be in cache for next 15 minutes.

rajalokan
  • 481
  • 4
  • 5