Difference between revisions of "Git cheatsheet"
From PC2wiki
m (→git cli: added section) |
m (→git cli: created a section per git command/item) |
||
Line 8: | Line 8: | ||
git Command-line interface commands | git Command-line interface commands | ||
− | Find all changes between workspace (gitspeak: working tree) | + | === Find all changes between workspace (gitspeak: working tree) === |
git status | git status | ||
− | Create branch foobar | + | === Create branch foobar === |
git branch -b foobar | git branch -b foobar | ||
− | Create and switch to foobar | + | === Create and switch to foobar === |
git checkout -b foobar | git checkout -b foobar | ||
− | Switch to branch foobar | + | === Switch to branch foobar === |
git checkout foobar | git checkout foobar | ||
− | Switch back to master | + | === Switch back to master === |
git checkout master | git checkout master | ||
− | List branches | + | === List branches === |
git branch | git branch | ||
− | List current branch | + | === List current branch === |
git status | git status | ||
− | Diff between current trunk (master) and branch, file names only | + | === Diff between current trunk (master) and branch, file names only === |
# git checkout foobar | # git checkout foobar | ||
git diff master --name-only | git diff master --name-only | ||
− | Diff between two branches, file names only | + | === Diff between two branches, file names only === |
git diff -name-only foobar branch2 | git diff -name-only foobar branch2 | ||
− | Create a label footag for current revision (gitspeak: tag) | + | === Create a label footag for current revision (gitspeak: tag) === |
git tag footag | git tag footag | ||
− | Label a previous version (foo.c commit 085398a) | + | === Label a previous version (foo.c commit 085398a) === |
$ git log --oneline foo.c | $ git log --oneline foo.c | ||
046d45e First working version | 046d45e First working version | ||
085398a First commit | 085398a First commit | ||
$ git tag footag 085398a | $ git tag footag 085398a | ||
− | List all labels (gitspeak: tags) | + | === List all labels (gitspeak: tags) === |
git tag | git tag | ||
− | List revisions in tree form | + | === List revisions in tree form === |
git log --oneline --graph --decorate --all | git log --oneline --graph --decorate --all | ||
Revision as of 21:31, 6 November 2014
This article is a collection of shortcuts and other helpful information about using git.
Contents
- 1 Other Resources
- 2 git cli
- 2.1 Find all changes between workspace (gitspeak: working tree)
- 2.2 Create branch foobar
- 2.3 Create and switch to foobar
- 2.4 Switch to branch foobar
- 2.5 Switch back to master
- 2.6 List branches
- 2.7 List current branch
- 2.8 Diff between current trunk (master) and branch, file names only
- 2.9 Diff between two branches, file names only
- 2.10 Create a label footag for current revision (gitspeak: tag)
- 2.11 Label a previous version (foo.c commit 085398a)
- 2.12 List all labels (gitspeak: tags)
- 2.13 List revisions in tree form
- 3 EGit
- 4 Other notes
- 5 todo
Other Resources
https://git.wiki.kernel.org/index.php/QuickStart
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
EGit
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 http://github.com/EsotericSoftware/yamlbeans git pull upstream master
todo
TBD summarize: git pick, git rebase, git squash, cherry-pick