Development Manager @ PITECH+PLUS
Symfony Certified Developer
Husband and dad
lenard.palko@gmail.com
@lenardpalko
Linus Torvalds
"git - the stupid content tracker"
free, open-source (https://github.com/git/git)
decentralised
suitable to handle large codebase
working directory
staging area
metadata
update
git add
git commit
$ git commit -m "The bets commit message ever."
[master 57d9fc9] The bets commit message ever.
1 file changed, 1 insertion(+)
create mode 100644 foo
$ git commit --amend
[master 59a5de1] The best commit message ever.
Date: Wed Apr 13 00:25:41 2016 +0300
1 file changed, 1 insertion(+)
create mode 100644 foo
Commit hash has changed so it's a different object
$ git rev-parse --abbrev-ref @{u}
To see what is the configured remote branch for the current branch
OR
$ cat .git/config
... and search for your branch
$ git pull --rebase
Pull can also rebase instead of merge
http://rypress.com/tutorials/git/media/5-1.png
git checkout feature
git merge master
git merge master feature
http://rypress.com/tutorials/git/media/4-1.png
http://rypress.com/tutorials/git/media/5-5.png
git checkout feature
git rebase -i master
pick 33d4a7a Commit message #1
pick 9543b3d Commit message #2
pick 5c87661 Commit message #3
pick 33d4a7a Commit message #1
fixup 9543b3d Commit message #2
pick 5c87661 Commit message #3
$ git add -i
staged unstaged path
1: unchanged +2/-2 file1
2: unchanged +1/-1 file2.php
*** Commands ***
1: status 2: update 3: revert 4: add untracked
5: patch 6: diff 7: quit 8: help
What now>
git push --force
4b825dc642cb6eb9a060e54bf8d69288fbee4904
git rev-parse master
commit 5584ba46f089c7389d9fbf7b1d371e468394bb84
Author: Web Developer <web@developer.com>
Date: Thu Apr 7 00:18:06 2016 +0300
Commit message details
.git/refs/
heads/
master
feature
remotes/
origin/
master
tags/
v0.1
$ git reflog
59a5de1 HEAD@{0}: commit (amend): Commit message #1.
57d9fc9 HEAD@{1}: commit (initial): Commit message #2.
$ git checkout HEAD@{1}
$ git reset --hard HEAD@{1}
#!/bin/sh
#!/usr/bin/env python
$ git config --global init.templatedir 'templatedir'
$ git log --graph --oneline --decorate
* 7a48ea2 (HEAD, master) Commit message #5.
* 075ce36 Commit message #4.
* 62cbf27 Merge branch 'branch'
|\
| * 5a40d5a Commit message branch#2.
| * dd0109a Commit message branch#1.
* | dd0f5d6 Commit message #3.
|/
* 13d1b4b Commit message #2.
* 45de2f7 Commit message #1.
Some visual tools : gitg, gitk, SourceTree
$ git shortlog
Penguin (2):
Added going for a swim feature.
Fix not working leg.
Archibald (3):
Added some voodoo magic.
Merge branch 'fix_leg'.
Playing with basic magic config.
$ git log sincerev..untilrev --summary --diff-filter=D
get all the files that were deleted between two revisions
$ git log --after="2016-4-1" --before="2016-4-12"
get commits between specific dates
$ git log --merges
get only comits with at least two parents
locate bug introducing commit
$ git bisect
see diff from staged files
$ git diff --cached
get commit from different branch
$ git cherry-pick sha1
safe revert public commit
$ git revert
setup shortcuts for your favourite commands
$ git config --global alias.visual '!gitk'
$ git config --global alias.unstage 'reset HEAD --'
$ git config --global alias.history 'log --graph --oneline --decorate'
$ git config --global alias.pr 'pull --rebase'
Commit often, commit small things, commit even stupid stuff because there is no downside, commits are small, commits are easy to work with, commits are easy to get rid of.
Linus Torvalds
http://marc.helbling.fr/2014/09/practical-git-introduction
http://marc.helbling.fr/talks/git.html
http://rypress.com/tutorials/git/the-basics
https://www.atlassian.com/git/tutorials/advanced-overview
https://en.wikipedia.org/wiki/Git_(software)
https://try.github.io
http://pcottle.github.io/learnGitBranching/
https://www.codeschool.com/courses/git-real