Git cheatsheet

From PC2wiki
Revision as of 20:10, 2 December 2014 by Doug Lane (talk | contribs) (EGit: add section)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This article is a collection of shortcuts and other helpful information about using git.

Other Resources

git cli

git Command-line interface commands

Find all changes between workspace (gitspeak: working tree)

git status

Create branch foobar

git branch -b foobar

Create and switch to foobar

git checkout -b foobar

Switch to branch foobar

git checkout foobar

Switch back to master

git checkout master

List branches

git branch

List current branch

git status

Diff between current trunk (master) and branch, file names only

# git checkout foobar
git diff master --name-only

Diff between two branches, file names only

git diff -name-only foobar branch2

Create a label footag for current revision (gitspeak: tag)

git tag footag

Label a previous version (foo.c commit 085398a)

$ git log --oneline foo.c
046d45e First working version
085398a First commit
$ git tag footag 085398a 

List all labels (gitspeak: tags)

git tag

List revisions in tree form

git log --oneline --graph --decorate --all

git build numbers


eclipse EGit plugin

For each cli item describe how EGit does the same operation

Other notes

Create a local repo and fetch from a github project

git init
git remote add upstream
git pull upstream master


TBD summarize/describe:

git pick
git rebase
git squash
git cherry-pick

See Also