Tan Li Hau
@lihautan
https://lihautan.com
Web Frontend - Platform
GIT GUDDER
https://youtu.be/vpFKAV1Zy5Y
GIT
- git merge
- git reset
- git cherry-pick
- git revert
- git rebase
- git log
- git reflog
- git bisect
GIT MERGE
"Fast Forward"
"Fast Forward"
"Fast Forward"
# in Branch A
git checkout branch-a
git merge master
# or
git merge --ff master
"Non-Fast Forward"
"Non-Fast Forward"
"Non-Fast Forward"
# in Branch A
git checkout branch-a
git merge master
# or
git merge --no-ff master
GIT PULL
= git fetch origin branch-a
+ git merge origin/branch-a
GIT PULL
= git fetch origin branch-a
+ git merge origin/branch-a
GIT PULL
= git fetch origin branch-a
+ git merge origin/branch-a
git push origin branch-a
GIT RESET
GIT RESET --HARD
GIT RESET --HARD
git reset --hard branch-a
GIT RESET --HARD
git reset --hard branch-a
GIT RESET --HARD
git reset --hard #d
GIT RESET --HARD
git reset --hard #d
GIT CHERRY-PICK
GIT CHERRY-PICK
GIT CHERRY-PICK
git cherry-pick branch-a
GIT CHERRY-PICK
git cherry-pick branch-a
GIT CHERRY-PICK
git cherry-pick branch-c
GIT CHERRY-PICK
git cherry-pick branch-c
GIT REVERT
GIT REVERT
GIT REVERT
git revert #1
GIT REVERT
git revert #1
GIT REVERT
GIT REVERT
GIT REVERT
master: git revert #1
GIT REVERT
master: git revert #1
GIT REVERT
feat/a: git merge master
GIT REVERT
feat/a: git merge master
GIT REVERT
GIT REVERT
master: git merge feat/a
GIT REVERT
master: git merge feat/a
GIT REVERT
GIT REVERT
feat/a: git merge master
GIT REVERT
feat/a: git merge master
GIT REVERT
feat/a: git revert ~#1
GIT REVERT
feat/a: git revert ~#1
GIT REVERT
master: git merge feat/a
GIT REVERT
master: git merge feat/a
GIT REBASE
git rebase
branch-a branched out from master
git rebase
git rebase
# in Branch A
git checkout branch-a
git rebase master
git rebase
git rebase
git rebase
# in Branch A
git checkout branch-a
git rebase --onto branch-b master branch-a
git rebase
# in Branch A
git checkout branch-a
git rebase --onto branch-b master
git rebase
# in Branch A
git checkout branch-a
git rebase --onto branch-b #1
#1
git rebase
# in Branch A
git checkout branch-a
git rebase --onto #1 #1
#1
git rebase
# in Branch A
git checkout branch-a
git rebase #1
#1
git rebase --interactive
#1
git rebase --interactive
#1
git rebase -i #1
#2 pick commit msg 2
#3 pick commit msg 3
#4 pick commit msg 4
#5 pick commit msg 5
#6 pick commit msg 6
git rebase --interactive
#1
git rebase -i #1
# Rebase #1..#6 onto #1 (5 commands)
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
...
git rebase --interactive
#1
git rebase -i #1
#2 pick commit msg 2
#3 drop commit msg 3
#4 pick commit msg 4
#5 pick commit msg 5
#6 pick commit msg 6
git rebase --interactive
#1
git rebase -i #1
#2 pick commit msg 2
#3 drop commit msg 3
#4 pick commit msg 4
#5 pick commit msg 5
#6 pick commit msg 6
git rebase --interactive
#1
git rebase -i #1
#2 pick commit msg 2
#3 squash commit msg 3
#4 pick commit msg 4
#5 fixup commit msg 5
#6 pick commit msg 6
git rebase --interactive
#1
git rebase -i #1
#2 pick commit msg 2
#3 squash commit msg 3
#4 pick commit msg 4
#5 fixup commit msg 5
#6 pick commit msg 6
git rebase --interactive
#1
git rebase -i #1
#2 pick commit msg 2
#3 pick commit msg 3
break
#4 pick commit msg 4
#5 pick commit msg 5
#6 pick commit msg 6
git rebase --interactive
#1
git rebase -i #1
#2 pick commit msg 2
#3 pick commit msg 3
break
#4 pick commit msg 4
#5 pick commit msg 5
#6 pick commit msg 6
git rebase --interactive
#1
git rebase -i #1
Stopped at #3... commit msg 3
$ git status
interactive rebase in progress; onto 594531e
Last commands done (2 commands done):
...
(see more in file .git/rebase-merge/done)
Next commands to do (3 remaining commands):
...
git rebase --interactive
#1
git rebase -i #1
...
$ git add .
$ git commit -m "commit msg 3.1"
git rebase --interactive
#1
git rebase -i #1
...
$ git add .
$ git commit -m "commit msg 3.1"
git rebase --interactive
#1
git rebase -i #1
$ git rebase --continue
git rebase --interactive
#1
git rebase -i #1
$ git rebase --continue
git rebase --interactive
#1
git rebase -i #1
#2 pick commit msg 2
#3 edit commit msg 3
#4 pick commit msg 4
#5 pick commit msg 5
#6 pick commit msg 6
git rebase --interactive
#1
git rebase -i #1
...
$ git add .
$ git rebase --continue
git rebase --interactive
#1
git rebase -i #1
...
$ git add .
$ git rebase --continue
git rebase --interactive
#1
git rebase -i #1
#2 pick commit msg 2
#3 reword commit msg 3
#4 pick commit msg 4
#5 pick commit msg 5
#6 pick commit msg 6
git rebase --interactive
#1
git rebase -i #1
# abort
$ git rebase --abort
# continue
$ git rebase --continue
GIT PULL
= git fetch origin branch-a
+ git merge origin/branch-a
GIT PULL --REBASE
= git fetch origin branch-a
+ git rebase origin/branch-a
GIT PULL --REBASE
= git fetch origin branch-a
+ git rebase origin/branch-a
git rebase
git rebase
git rebase
git rebase
git rebase
git rebase
git rebase
git rebase
GIT LOG
git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
aliased to glol
--since=<date>
--after=<date>
--until=<date>
--before=<date>
--grep=<pattern>
--invert-grep
--all-match
--min-parents=<number>
--max-parents=<number>
--merges
--no-merges
--first-parent
GIT REFLOG
GIT BISECT
$ git bisect start $ git bisect bad v2.5.1 $ git bisect good v2.6.13
$ git bisect start $ git bisect bad v2.5.1 $ git bisect good v2.6.13
Bisecting: 675 revisions left to test after this (roughly 10 steps)
$ git bisect start $ git bisect bad v2.5.1 $ git bisect good v2.6.13
Bisecting: 675 revisions left to test after this (roughly 10 steps)
$ git bisect good
$ git bisect start $ git bisect bad v2.5.1 $ git bisect good v2.6.13
Bisecting: 675 revisions left to test after this (roughly 10 steps)
$ git bisect good
Bisecting: 337 revisions left to test after this (roughly 9 steps)
$ git bisect start $ git bisect bad v2.5.1 $ git bisect good v2.6.13
Bisecting: 675 revisions left to test after this (roughly 10 steps)
$ git bisect good
Bisecting: 337 revisions left to test after this (roughly 9 steps)
$ git bisect bad
$ git bisect start $ git bisect bad v2.5.1 $ git bisect good v2.6.13
Bisecting: 675 revisions left to test after this (roughly 10 steps)
$ git bisect good
Bisecting: 337 revisions left to test after this (roughly 9 steps)
$ git bisect bad
Bisecting: 168 revisions left to test after this (roughly 8 steps)
$ git bisect start $ git bisect bad v2.5.1 $ git bisect good v2.6.13
Bisecting: 675 revisions left to test after this (roughly 10 steps)
$ git bisect good
Bisecting: 337 revisions left to test after this (roughly 9 steps)
$ git bisect bad
Bisecting: 168 revisions left to test after this (roughly 8 steps)
$ git bisect reset
good / bad
old / new
good / bad
old / new
git bisect start --term-old fast --term-new slow
THANK YOU
GIT: Manipulating your history
By Li Hau Tan
GIT: Manipulating your history
- 2,131