This page is my own personal work. Anyone can use it for their own edification, but must realize that this material is not supported by me and the site is not affiliated with IBM Rational Software or Atlassian.
Create a new branch.
git branch branch-nameTable of Contents
Switch branches (checkout).
git checkout branch-nameTable of Contents
Merge branches.
git merge branch-nameTable of Contents
View branch history.
gitkTable of Contents
Push a branch to a remote repository.
git push remote-name branch-name Ex: git push origin masterTable of Contents
Add a file to source control (tracking).
# Single file git add file # All files, as when you initialized the repository's content. git add --all -or- git add . git commit
Merge a single file.
Ignore certain untracked files.
# Use pound signs to add comments. *.jar # Ignore all .jar files. *.[oa] # Ignore all files ending .o or .a. !*.c # Ignore all files expect .c files (negation).
Automatically commit unstaged changes.
git commit -a -m commit-messageTable of Contents
Remove a file from tracking.
git rm file # Leave the file in your working tree, but stop tracking. git rm --cached fileTable of Contents
Rename a file.
git mv old-name new-name # This is the same as: move/mv old-name new-name git rm old-name git add new-nameTable of Contents
Unstage a change.
git status git reset HEAD fileTable of Contents
Revert a file to what is in the repository.
git checkout fileTable of Contents
View commit history.
git log
View commit history.
Push committed changes to the centrol repository.
git remote --verbose git push remote-repo-name branchTable of Contents
Add files with very long paths.
git config --global core.longpaths trueTable of Contents
Create a hook.
Centralize the management of hooks.
Get the current status of changes and staging.
git statusTable of Contents
Set global configuration information.
git config --global user.name "Your Full Name" git config --global user.email you@yourdomain.example.com git config --global core.longpaths trueTable of Contents
Git interfaces, front-ends, and tools.
Get command help.
git --help commandTable of Contents
Implement a Git commit message template.
Change where Git finds your home directory.
Set a Git config that gets inherited by all Clones.
Create a repository.
mkdir repository-folder cd repository-folder git initTable of Contents
Clone a repository.
git clone URL
Determine if a repository is bare.
git rev-parse --is-bare-repositoryTable of Contents
Link to a remote repository.
git remote add origin URLTable of Contents
Delete a repository.
git remote set-url --delete repository-name-being-deleted URLTable of Contents
Change the URL associated with a remote repository.
git remote set-url remote-repo-name "URL" git remote --verboseTable of Contents
Fork a repository.
Find where Stash is installed.
Locate where Stash stores repositories.
Uninstall Stash.
Create a tag.
# Lightweight git tag tag-name # Annotated git tag -a -m "comment" tag-nameTable of Contents
Create a user in a Stash instance.
# Create the user. stash --action addUser --server stash-server --user admin --password admin-password --userId user --userFullName "fullname" --userEmail email --userPassword password # Add the user to a project. stash --action grantProjectPermissions --server stash-server --user admin --password admin-password --project project --permission permission --userId user # Or, add the user to a group that already access to a project/repository. stash --action addUserToGroup --server stash-server --user admin --password admin-password --userId user --group groupTable of Contents
Create a Stash group.
Add a group to a repository.
Reset a user's password.
Remove a group from a project.