Branch Create | git branch new-branch-name | Create a new branch from head (active branch checked out). | git-scm: git-branch |
Branch List | git branch | List available local branches. The current branch checked out is noted with an asterisk. | |
Branch Delete | git branch -d branch-name | Delete/remove a branch from local repository. | |
Branch Rename | git branch -m old-branch-name new-branch-name | Rename/Move a branch from local repository. | |
Clean | git clean -d -f -x | Remove all files not under source control. | |
Clone | git clone URL | Clone a repository from remote to local | git-scm: git-clone |
Clone | git clone git@hostname:project-name.git | | |
Clone | git clone -b branch-name git@git.example.com:site/project.git | Clone a repository from a remote to local of a specific branch. | |
Checkout | git checkout master | Checkout local branch called "master". | git-scm: git-checkout |
Checkout Branch | git checkout -b new-branch-name | Create a new branch from head (active branch checked out) and then checkout new branch. | git-scm: git-checkout |
Commit | git commit -am "Add the message" | Commit all stage files with an associated message. | git-scm: git-commit |
Config | git config -l | List all of the git config | |
Diff | git diff | Show changes between commits, commit and working tree, etc. | git-scm: git-diff |
Init | git init | Create an empty Git repository. | git-scm: git-init |
Log | git log | Show commit logs from the working tree. | git-scm: git-log |
Local Add | git add readme.md | Add a specific file for commit. | git-scm: git-add |
Local Add | git add . | Add recursively all files/directories for commit. | git-scm: git-add |
Merge | git merge branch-name | Merge a local branch into current head (active branch). | git-scm: git-merge |
Patch Create | git format-patch master --stdout > fix.patch | Creates a patch file for all the changes from the current branch to the master branch. | How to create and apply a patch with Git |
Patch Stat | git apply --stat fix.patch | Show what the patch will be doing. | |
Patch Check | git apply --check fix.patch | Apply the patch as a test to see if it will work before actually applying the patch. | |
Patch Apply | git apply < fix.patch | Apply the patch to the current head. | |
Patch Apply | git am --signoff < fix.patch | Apply the patch to the current head and signoff. | |
Pull | git pull origin develop | Fetches and then merges changes from origin (remote repository) from the develop branch. | git-scm: git-pull |
Pull | git pull | Fetches and then merges changes from tracked head. | |
Push | git push origin develop | Update origin (remote repository) to the develop branch from local. | git-scm: git-push |
Remote | git remote -v | List the set of tracked repositories with URL. | git-scm: git-remote |
Remote Add | git remote add origin url | Add a remote repository. | |
Remote Remove | git remote remove origin | Remove a remote tracked repository by name from local. | |
Reset | git reset hash | Reset current HEAD to the specified state. Replace "hash" with the desired state in which to go back to. | git-scm: git-reset |
Show | git show | Show various types of objects. | git-scm: git-show |
Stash | git stash | Stash the changes in a dirty working directory away. | git-scm: git-stash |
Stash Drop | git stash drop | Remove a single stashed state from the stash list. When no is given, it removes the latest one (i.e. stash@{0}). | |
Stash Save | git stash save stash-name | Save your local modifications to a new stash, and run git reset --hard to revert all changes back to current state. | |
Stash Show | git stash show | Show the changes recorded in the stash as a diff between the stashed state and its original parent. | |
Stash List | git stash list | List the stashes that you currently have listed in newest to oldest. | |
Stash Pop | git stash pop | Remove a single stashed state from the stash list and apply it on top of the current working tree state. | |
Status | git status | Show the working tree status (changes). | git-scm: git-status |
Tag List | git tag | List the tags within the checked out branch. | git-scm: git-tag |
Tag a Commit | git tag -a 1.1.19 5acaeb1 -m "Added comments home.ctp." | Add an annotate to specific commit (hash) with a message. | |