Skip to content

Instantly share code, notes, and snippets.

@kkayacan
Last active July 6, 2020 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkayacan/fe1779f0dbb0f6e5b7da37a88d77adee to your computer and use it in GitHub Desktop.
Save kkayacan/fe1779f0dbb0f6e5b7da37a88d77adee to your computer and use it in GitHub Desktop.
Git quick reference
• Clone an existing remote repository to local
git clone https://github.com/username/project.git
• If starting from local (not cloning remote repo), initialize repository
git init
• Check status (changes since last commit) (optional)
git status
• Add all changes to staging (next commit). Notice "dot" at the end.
git add .
• Commit changes (create new commit). Text between double quotes is explanatory comment.
git commit -m "first commit"
• If started from local, set remote origin (repository on Github, Bitbucket, Gitlab). Remote repository must exist.
git remote add origin https://github.com/username/project.git
git remote add origin https://bitbucket.org/username/project.git
• If you don't want to be asked for password at every push, set for credential cache
Linux:
git config credential.helper store
Windows:
git config --global credential.helper wincred
• Push (upload) changes to remote origin. Git will ask for login info (user, pass).
git push -u origin master
• See local modifications
git diff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment