Site icon Alchemista

Add ID and Password to git with https

I’ve got the AWS VPC environment which is not allowing SSH outbound connection but https.

I have git server sitting outside, and I needed to switch from SSH to HTTPS.

I also wanted to save my credential into the server, so that I won’t have to keep typing my ID/PW.

Steps

Here is how.

  1. Create a user just for the server to pull code. So that even it was hacked, we just need to reset the user
  2. Clone git using https connection. If you are using GitHub, you can clone using HTTPS connection
  3. type the following config to register your credential
cd [git repo]
git config credential.[Git HTTPS DOMAIN] [username]
git config credential.helper store
git fetch -v
# it will ask username and password. Enter those

Done.

From next time when you use git command such as git pull or fetch to communicate with origin server, it won’t ask your ID & Password.

The credential info is stored as .git-credential text file on your home directory as plain text.

Reference

Read the official documentation of git.

Exit mobile version