Command | Description |
---|---|
git config --global user.name "[firstname lastname]" |
set a name that is identifiable for credit when reviewing version history |
git config --global user.email "[valid-email]" |
set an email address that will be associated with each history marker |
git status |
changed files in your working directory |
git remote -v |
list all currently configured remotes |
Command | Description |
---|---|
git init |
create empty Git repo in specified directory |
git clone <repo url> |
clone repo located at <repo> onto the local machine. |
git status |
changed files in your working directory |
git remote -v |
list all currently configured remotes |
Command | Description |
---|---|
git add . |
stage all changes for the next commit |
git add <directory> |
stage all changes in <directory> for the next commit |
git reset <file> |
unstage a file while retaining the changes in the working directory |
git diff |
diff of what is changed but not staged |
git diff --staged |
diff of what is staged but not yet committed |
git commit -m "<message>" |
Commit the staged snapshot and include a message about this commit |
Command | Description |
---|---|
git log |
show all commits, starting with newest |
git blame <file> |
show who changed what and when |
Command | Description |
---|---|
git branch |
list all existing branches |
git checkout <branch> |
switch to another branch and check it out into your working directory |
git checkout -b <branch> |
make a new branch and switch HEAD branch |
Command | Description |
---|---|
git remote add <url> |
create a new connection to a remote repo. |
git fetch <remote> <branch> |
fetches a specific <branch> , from the repo. Leave off <branch> to fetch all remote refs. |
git pull <remote> |
fetch the specified remote's copy of the current branch and immediately merge it into the local copy. |
git push <remote> <branch> |
Push the branch to <remote> , along with necessary commits and objects. Creates named branch in the remote repo if it doesn't exist. |
Command | Description |
---|---|
git merge <branch |
merge the specified branch's history into the current one |
git log |
show all commits in the current branch's history |
git rebase <branch> |
rebase your current HEAD onto <branch> |
Command | Description |
---|---|
git reset |
merge <branch> into your current HEAD |
git rebase <branch> |
apply any commits of a current branch ahead of specified one |