Commit 0aa8c6ad authored by nvmnghia's avatar nvmnghia

Update README.md

parent 25509593
...@@ -117,7 +117,7 @@ Git advantage: ...@@ -117,7 +117,7 @@ Git advantage:
2. Branch 2. Branch
- Remind: branch = commit pointer - Remind: branch = commit pointer
- Default: points at the **top** - Default: points **top** of branch
- `git branch` - `git branch`
- `new_name`: new branch - `new_name`: new branch
- `-m new_name`: rename current - `-m new_name`: rename current
...@@ -128,22 +128,7 @@ Git advantage: ...@@ -128,22 +128,7 @@ Git advantage:
- Branch can points at non-top commit - Branch can points at non-top commit
- See `git checkout` - See `git checkout`
3. `HEAD` & special pointers 3. Tag
- `HEAD`: points *current checked-out*
- Usually is a branch
- Can also be a commit -> detached `HEAD`
- More on `checkout` later
- Etym: top of the branch
- One of special pointers
- git handles what is pointed
- E.g.: `REVERT_HEAD`, `CHERRY_PICK_HEAD`,...
```bash
# Move HEAD to sth
git checkout sth
```
4. Tag
- Still pointers! - Still pointers!
- Difference: - Difference:
- Branch/`HEAD`: move with commits - Branch/`HEAD`: move with commits
...@@ -155,23 +140,49 @@ Git advantage: ...@@ -155,23 +140,49 @@ Git advantage:
git tag tag_name git tag tag_name
# annotated - have message # annotated - have message
git tag tag_name -m "tag message" git tag tag_name -m "tag message"
# Move to a tag
git checkout tags/tag_name
```
4. `HEAD` & special pointers
- `HEAD`: points *current checked-out*
- Usually is a branch
- Can also be a commit -> detached `HEAD`
- HEAD is closely related to `checkout`
- More on `checkout` later
- Etym: top of the branch
- `HEAD` is one special pointer
- Git manages these
- Other special pointers:
- `REVERT_HEAD`
- `CHERRY_PICK_HEAD`
- ...
```bash
# Move HEAD to sth
git checkout sth
``` ```
5. Relative ref 5. Relative ref
- Raw pointers are dirty -> Meet relative ref - Raw pointers are dirty -> Meet relative ref
- NO one remebers commit id
- *Even* Thanh
- `~` & `^`: back reference suffix - `~` & `^`: back reference suffix
- Similarity: - Similarity:
- Go with number: `master~5` - Go with number: `master~5`
- Chainable: `HEAD^~^` - Chainable: `HEAD^~^`
- `~n`: Go up nth generation, at the first parent - `~n`: Go up n<sup>th</sup> generation, at the first parent
- For dummies: Go up **ancestor** - For dummies: Go up **ancestor**
- `~` == `~1` - `~` == `~1`
- `~2`: first parent's first parent - `~2`: first parent's first parent
- `^n`: Go up to the nth parent (if > 1 parents) - `^n`: Go up to the n<sup>th</sup> parent (if > 1 parents)
- For dummies: Go up **parent** - For dummies: Go up **parent**
- `^` == `^1` - `^` == `^1`
- `^3`: third parent - `^2`: depends:
- Equal `~` if **no** merge commit along the path - Merge commit: second parent
- Otherwise: like `~2`
- Equal `~` if **not** merge commit
- Why 2 methods? - Why 2 methods?
- DAG != tree - DAG != tree
...@@ -179,7 +190,6 @@ Git advantage: ...@@ -179,7 +190,6 @@ Git advantage:
graph BT graph BT
classDef master fill:#418a44; classDef master fill:#418a44;
subgraph ref_each_node_from_HEAD
C1((C1)); C1((C1));
C2((C2)) -- "HEAD~4" --> C1; C2((C2)) -- "HEAD~4" --> C1;
C3((C3)) -- "HEAD~^2~~" --> C1; C3((C3)) -- "HEAD~^2~~" --> C1;
...@@ -191,7 +201,6 @@ Git advantage: ...@@ -191,7 +201,6 @@ Git advantage:
m("->master<-") --> C7; m("->master<-") --> C7;
class m master; class m master;
end
``` ```
6. Refspec 6. Refspec
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment