0

Anyone know how to set it up so when I'm in the command line and when I push/pull to/from a git repository I don't have to type in my username and password?

Thanks.

TheGeorgeous
  • 3,927
  • 2
  • 20
  • 33
Yi Lu
  • 163
  • 1
  • 6
  • Possible duplicate of [Git push requires username and password](http://stackoverflow.com/questions/6565357/git-push-requires-username-and-password) – TheGeorgeous Apr 24 '16 at 06:50

1 Answers1

4

When you use http/https as your transfer protocol you will be asked for username & password every time.

Switch to ssh key and you will not be asked anymore.

The sample below is how to set the key for GitHub, but i will be same for most of the servers with a minor changes (GUI).

The process is still the same

  • Generate ssh-key
  • Add the key to the server
  • Change the protocol to ssh (git://)

Here is how to set it up:

  • Generate a new ssh key (or skip this step if you already have a key as you mentioned )
    ssh-keygen -t rsa -C "your@email"

  • Once you have your key set in home/.ssh directory (or Users/<your user>.ssh under windows), open it and copy the content to the relevant section (ssh keys) under your central repository.


For more information about the transport protocols read this:


How to set up ssh key under your GitHub account?

  • Login to GitHub account
  • Click on the rancher on the top right (Settings)
    enter image description here
  • Click on the SSH keys and GPG Keys
    enter image description here
  • Click on the New SSH key
    enter image description here
  • Paste your key and save

Now it should work


Note

After the first set up open terminal and run a git fetch so the key will be tested and added to your known hosts file.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167