-
git init
'Cuz it's git innit? Use
git initto initialize a repository in the current directory. This command creates a hidden .git directory in the current folder containing the git repository and configuration files. -
git remote add origin [url]
After using
git initto initialize a repository on the local machine, use this command to link the local repository to an empty remote repository. This allows syncing with GitHub usinggit pushandgit pull. -
git clone [url]
Creates a local working copy of the source code from a remote repository.
git cloneautomatically downloads the code and adds the original location as the remote so you can pull code from or push code to it (if you have permission!). -
git status
Shows status of current branch and any changes. Changes not yet staged for commit are displayed in red, staged commits are in green.
-
git add [filename]
Adds file(s) to the staging area. Any changes will be included with next commit.
-
git commit
Save any changes you've made to your local repository. Each time you commit, you have to include a brief message. This message should include a brief description of the changes made.
-
git fetch
Downloads all history from remote tracking branches.
-
git merge
Merges remote tracking branches into local branch.
-
git pull
Updates local working branch with all new commits from remote branch. (
git pullis a combination ofgit fetchandgit merge). -
git push
Uploads all local branch commits to GitHub.