What every developers should know
Unlike other VCS, git take a snapshot of your code, not difference
Git doesn’t store a file again, if it has not changed
Link to the previous identical file it has already stored
Commit is a snapshot of your code
Each commit has unique hash (using SHA-1)
The commit hash is check-sum of all files
Each commit may have 0 (only initial commit) or more parent
--patch (-p)
--all (-a)
--patch (-p)
New files and directory
Tracked files (committed before) but has changd
Changes that are ready for commit
--oneline
--pach (-p)
git log <since>..<until>
git log <file>
git log --graph --decorate --oneline
--author
--grep
HEAD is a reference to current active commit
git checkout <branch-name>
git checkout <commit-hash>
* Detached HEAD
git checkout <commit-hash> <file>
git checkout <branch> <file>
^ modifier
~ modifier
A = = A^0
B = A^ = A^1 = A~1
C = A^2 = A^2
D = A^^ = A^1^1 = A~2
E = B^2 = A^^2
F = B^3 = A^^3
G = A^^^ = A^1^1^1 = A~3
H = D^2 = B^^2 = A^^^2 = A~2^2
I = F^ = B^3^ = A^^3^
J = F^2 = B^3^2 = A^^3^2
project $ git revert <commit-hash>
[<branch> <short-commit-hash>] Revert <commit-message>
n file changed, m insertion(+), t deletion(-)
project $
project $ git reset <commit-hash>
Unstaged changes after reset:
M index.php
M app/routes.php
M app/controllers/AdminController.php
project $
--soft
--hard
-n
-d
-f
-x
project $ git commit -am "Add new hello.php"
project $ git add required.php
project $ git commit --amend --no-edit
git remote add <name> <url>
git remote rename <old> <new>
git remote remove <name>
git remote
git brach
git branch <new-branch-name>
git branch -d <branch-name>
git branch -D <branch-name>
git branch -m <branch-new-name>
git merge <branch-name>
git merge --no-ff <branch-name>
Base
Fork 1
Fork 2