Git advanced
-
Upload
peter-vandenabeele -
Category
Software
-
view
582 -
download
0
Transcript of Git advanced
disclaimer
● from the trenches● opiniated (git cherry-pick)● not complete● going deep (feel free to disconnect)
contents
● always start with “Why ?”● GitX and other GUI’s● fundamentals● git init, git status, git add -i, git commit● git remote -v, git init --bare● git branch -a, git merge, git rebase -i● git cherry-pick, git log --author
WHY ? (peter_v)
● I <3 git , because now = ∅ + Σ commits● I was there too, so maybe this helps ?
detached head ???
GUI’s for git
● multi-OS : Tower, Github, SourceTree …● Mac : GitX-dev (rowanj fork)● Linux : gitk● I use GitX-dev + command line● overview (next pages):
https://git-scm.com/downloads/guis
remoteremote
fundamentals
working dir
index
repository
remote(s)
git add
git commit
git push
git checkout
git fetch
origin
git merge
⇐ NON-local
⇐ ALL local
upstream
git init
$ git init git-advanced
● creates a repository in ../.git● interesting: config, hooks, logs, refs● does a local git checkout● all state is inside the dir (mv, tar, cp -r, …)
after git init (2)
working dir
index
repository
remote
git add
git commit
git push
git checkout
git fetch
origin
git merge
git status
$ git status
● “safe” command (always first)● files/changes NOT yet in index => red● files/changes in index => green
$ alias gst=’git status’
before git add
working dir
index
repository
remote
git add
git commit
git push
git checkout
git fetch
origin
git merge
git add -i
$ git add -i
● fine grained control of commits● always do “4” first
GOTCHA => new files not shown $%#!(“untracked files”)
git commit
● what really is it ??● identified by a recursive sha (long, short 7)● relative: a DIFF between “parent” and “this”● absolute: ∅ + Σ (parent) commits● only 1 parent ? NO (merge, non fast-forward)
git remote
● git remote -v● on server
○ mkdir git-advanved.git○ cd git-advanced.git○ git init --bare .
● git remote add origin [email protected]:/data/git/git-advanced.git
git branch
* git branch -a
* git pull = git fetch + git merge
* git rebase origin/master
* fast forward
git rebase -i
* git rebase -i
(--continue --abort --skip)
* clean up large binary commits
* git push force
git rebase vs. merge
* rebase frequently with /01 /02 branches
* squash (git rebase -i) if needed
* tests can be run locally by developer (also possible with "git merge master")