Git Quick Reference

I don’t use Git everyday, but when I do, I use these commands, and when I do, I promptly forget them.

First set up the repo in Github then push into the remote repo.

Desired OutcomeCommandNotes
Display the version
git –version
Create a new local repogit init
Identify yourself via name and email address and these will show up in the git commits.git config –global user.name “Johann Bach”

git config –global user.email “johann.bach@harpsichord.com”

use git config –local to modify the local repo
Update the index with all files in the working treegit add –all
Limit how long credentials are cached.git config credential.helper ‘cache –timeout 900’git config credential.helper cache
git push http://example.com/repo.git
Username:
Password:

[work for 5 more minutes]
git push http://example.com/repo.git
[your credentials are used automatically]

Store your repo credentials indefinately
git config credential.helper store

git config credential.helper store

git push http://example.com/repo.git
Username:
Password:

[several days later]
git push http://example.com/repo.git
[your credentials are used automatically]

Exit git early, forgetting all cached credentialsgit credential-cache exit
git commit -m “Insert Commit Message Here”
git status
git push
git config credential.helper ‘store –file ~/.git-credentials’Research this one a bit more.
vi .gitconfig