Skip to content

Instantly share code, notes, and snippets.

@jrc03c
Last active April 19, 2023 20:05
Show Gist options
  • Save jrc03c/3aad806bafd9dc2c75b3c270854493c0 to your computer and use it in GitHub Desktop.
Save jrc03c/3aad806bafd9dc2c75b3c270854493c0 to your computer and use it in GitHub Desktop.
Git Cheat Sheet
##################
Basic Git Commands
##################
git init = turns the current working directory into a repository
git clone = downloads a remote repository to your machine
Syntax: git clone <source> <destination>
Example: git clone https://github.com/willfind/uplift-website /home/josh/projects/uplift.app
git pull = downloads the latest updates from remote repositories
Syntax: git pull <source> <branch>
Example: git pull origin master
Example: git pull
(uses the default source and current branch)
git add = stages files to be committed to the repository's history
Syntax: git add <file>
Example: git add readme.md
Example: git add . --all
(the --all flag tells git to include deletions on the stage)
git commit = commits changes to the repository's history
git push = uploads updates to remote repositories
Syntax: git push <destination> <branch>
Example: git push origin master
git stash = hides "dirty" (uncommitted) changes to the repository
Example: git stash -u
(the -u flag tells git to stash newly-created files)
Example: git stash clear
(this clears the current stash)
###################
My Typical Workflow
###################
1. Clone the remote repository.
2. While the project is unfinished:
a. Pull changes from the remote repository to make sure it's up-to-date.
b. Make changes.
c. Stage (add) changed files.
d. Commit staged files.
e. Push commits to the remote repository.
3. Celebrate!
@meatnordrink
Copy link

Wonderful, thanks Josh!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment