.git/objects /f4/8011a40ba2f5b9f6af3b387e
-
This is the "heart" of git, but not the brains
-
key-value store (key == sha1!)
-
blobs
-
trees
-
refs
- commits, branches, tag, HEAD
-
private? Go nuts!
git commit --amend git push --force origin master git rebase --onto origin/master
-
public? Use merge! It has benefits, I swear!
http://www.mail-archive.com/[email protected]/msg39091.html
I want clean history, but that really means (a) clean and (b) history.
People can (and probably should) rebase their private trees (their own work). That's a cleanup. But never other peoples code. That's a "destroy history"
You must never EVER destroy other peoples history. You must not rebase commits other people did. Basically, if it doesn't have your sign-off on it, it's off limits: you can't rebase it, because it's not yours.
https://www.atlassian.com/git/tutorials/merging-vs-rebasing
* - * - A - B <- master
\
- C - D <- you are here
git rebase --onto master git rebase master
* - * - A - B <- master
\
- C - D <- now you are here
Linear history is nice to have:
* - * - A - B - C - D <- you
^ master
git rebase -i master
- move important commits to beginning
- cleanup/whitespace to end
- squashes and uses first commit message
- squashes and preserves commit messages
- finicky!
-
maybe not as useful
git rebase --abort git rebase --cont git rebase --skip
MERGE THEORY
* - * - A - B - master
\
- C - D <- you are here
git merge master
* - * - A - B <- master
\ \
- C - D - + <- now you are here
-
merge commits are "nothing special" (but yes, they are)
-
traversing history through merge commits? compare commits!
git log HEAD ^master # only show MY history, nothing that is in master
-
git reflog
- Records HEAD changes
-
git fsck --lost-found
- Is pretty cool
- personal fav:
git log
--pretty=format:'%Cred%h%Creset - %Cgreen%ci%Creset%C(yellow)%d%Creset %s %Cblue(%cn)%Creset'
# --pretty=format:'%h - %ci%d %s (%cn)'
--abbrev-commit
--date=relative
--graph
git ll
git log -p
git log --stat
git log --author 'Colin'
git log --author 'steam\|process255\|sean'
~/.gitconfig
git config --global alias.st status
Really common, highly recommended:
st = status
br = branch
ci = commit
co = checkout
alias g=git
# for the supremely lazy
g st
g co - # checkout previous branch
g ci -am "your message here" # commit all changes w/ commit message
[alias]
ignore = !([ ! -e .gitignore ] && touch .gitignore) | echo $1 >>.gitignore
grab = ![[ -n "$1" ]] && git fetch origin $1:$1 || echo "You must specify a branch"
git ignore [file]
git grab master # updates master, you don't change branches
# git fetch origin master:master
git rebase master
git my
# git log HEAD ^master
# all files being tracked
git ls-files
git diff --patience -w # ignore whitespace
git diff --color-words # show word changes (instead of line changes)
git diff --cached # show changes *about* to be committed
https://git-scm.com/book/en/v2 https://www.atlassian.com/git/tutorials