Git: Save credentials for pushing over https on macOS
Setup existing folder as repo
Initialise repository
For my personal git server, I like to use HTTPS instead of SSH, because it runs behind a reverse proxy without SSH ports exposed to the internet.
cd ~/Documents/docs
git init
git remote add origin https://git.example.org/user/docs.git
git add .
git commit -m "Initial commit"
git push -u origin master
If find typing credentials every time I interact with a remote repository annoying. To prevent this, git can be set up with credential-osxkeychain using the following command:
git config --global credential.helper osxkeychain
Now, git will save credentials in macOS built-in keychain upon first entry and won’t ask for them again.