git clone ssh://[email protected]/repoName.git
Clone an exisiting repository
git init
Create a new local repository (do this if one isn't already made in GitHub)
git status
View changed files in your working directory (includes untracked files)
git diff
View changes to tracked files
git add .
Add all current changes to the next commit (called staging
)
git add <fileOrFolderName>
Add only particular file's or directory/folder's changes to next commit
git commit -a
Commit all local changes in tracked files (won't use as much)
git commit -m "reason for commit"
Commit changes and write a message for what you're committing (will use primarily)
git commit --amend
Change the last commit (don't do this after a git push
)
git remote -v
List all currently attached remotes
(GitHub / Heroku are remotes
of your local Git)
git remote show <remoteName>
Show information about a remote
git remote add <remoteName> <remoteURL>
Add new remote repository
git remote rm <remoteName>
Remove remote repository by name
git fetch <remoteName>
Download all changes from (typically origin
) but don't integrate/merge into files just yet
git pull <remoteName> <branch>
Download changes from (typically origin
) and it's particular branch (typically master
)
git push <remoteName> <branch>
Publish local changes on a remote to a particular branch (i.e. git push origin master
). You do this AFTER a git add
and git commit
so Git knows what you're pushing up.
git branch -dr <remoteName/branch>
Delete a particular branch from remote
git branch -av
List all available branches and most recent commits to each
git branch <branchName>
Create a new branch based on your current HEAD or step into a local branch
git checkout -b <branchName>
Create a new local branch and step into it
git reset --hard HEAD
Discard all local changes in your working directory
git reset --hard origin/master
Discard all local changes and making it match the remote and base (GitHub repo)
git revert <commitCode>
Revert a commit (commitCode
will be provided to you by typing in git log
and getting the associated code with it)