5. Git: Reference
➔ git branch
➔ git tag
➔ HEAD, ORIG_HEAD, FETCH_HEAD
Notice:
1. Each reference points to a commit (Hash)
2. Low cost to move a reference (FF)
11. git stash
● Temporary store the changes you made.
● Useful with rebase
Basic usage: stash <push, pop, list>
Extend Reading Material:
http://yodalee.blogspot.tw/2013/12/git-stash.html
12. git format-patch, am
● git format-patch <Ref>
○ generate patches
● git am <path-to-patch>
○ Apply patches
13. git bisect
Find the commit that changes somthing, steps:
1. bisect start
2. Set “bisect bad”, “bisect good”
3. Keep testing; set bad or good
4. Find the commit
Extend Reading Material:
http://yodalee.blogspot.tw/2014/08/git-bisect.html
14. git cherry-pick
Pick out the change in some commit.
● -n, --no-commit: allow you edit, commit
manually
Not very useful, actually.
15. Git inside
ls * in .git:
● Object/: Data
● Refs/: Reference
● Logs/: Change to Reference
● other files
Extend Reading Material:
http://git-scm.com/docs/gitrepository-layout
16. Git reflog
● View the list of HEAD movement. record the
Hash and action
● Log when you move reference by
<commit, rebase, reset, checkout>
If you get the Hash, you can recover it.
17. Git fsck
● Fsck check repository integrity, find dangling
commits.
● Even reflog is deleted or not record, ex:
git branch -D some-branch
rm -Rf .git/logs/
18. Git gc
● Git do 'git gc --auto' automatically, it will
○ Pack the loose files (refs->packed-refs)
○ Delete the Non-reference files.
19. Git filter-branch
Filter out some commits, and do some change.
ex. git filter-branch --msg-filter “echo XD” branch
--Change all commit message into “XD”
ex. git filter-branch --index-filter “rm xxx” branch
--Delete file from git repository
Extend Reading Material:
http://yodalee.blogspot.tw/2014/06/git-gc.html