Git and Mercurial Reference

Redirection notice

This page will redirect to /display/GSWBB/Git+and+Mercurial+commands .

If you've just started using Git or Mercurial, you may need to refer to this page a few times before you get the hang of it.

The Git commands with links open up our Getting Git Right website with more detailed information. For more commands, check out our Basic Git commands or the Mercurial Wiki for a more detailed comparison of Git to Mercurial.

Task Git commands Mercurial (Hg) commands
Create a new local directory: git init hg init
Connect your local repository to a remote server: git remote add origin <server_URL> hg push <server_URL>
Copy a remote repository to your local system:
git clone <URL_to_repository>
hg clone <URL_to_repository>
Add a specific file to staging (Git) or after a new file is created (Hg):
git add <filename>
hg add <filename>
Add all changes to staging (Git) or all new files (Hg):
git add --all
hg add
Commit changes locally:
git commit -m '<message>'
hg commit -m "<message>"
Push changes to your remote repository:

git push <remote_name> <branch_name>

usually: git push origin master

hg push
List the status of the files you've changed and those you still need to add or commit:
git status
hg status
Create a new branch (Git) or bookmark (Hg) and switch to it:
git checkout -b <branch_name>
hg bookmark <bookmark_name>
Switch from one branch or bookmark to another:
git checkout <branch_name>
hg bookmark <bookmark_name>
List all the branches/bookmarks in your repo with an indication of the one you are on:
git branch
hg bookmarks
Delete the feature branch/bookmark:
git branch -d <branch_name>
hg bookmark -d <bookmark_name>
Push the branch/bookmark to your remote repository:
git push origin <branch_name>
hg push -B <bookmark_name>
Fetch and merge changes on the remote server to your working directory:
git pull
hg pull -u
Merge two different revisions into one:
git merge
hg merge
Show all changes made since the last commit: git diff hg diff

Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport