Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Popular Science - Git
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nvmnghia
Popular Science - Git
Commits
0aa8c6ad
Commit
0aa8c6ad
authored
Oct 29, 2019
by
nvmnghia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update README.md
parent
25509593
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
34 deletions
+43
-34
README.md
README.md
+43
-34
No files found.
README.md
View file @
0aa8c6ad
...
...
@@ -117,7 +117,7 @@ Git advantage:
2. Branch
- Remind: branch = commit pointer
- Default: points
at the **top**
- Default: points
**top** of branch
- `git branch`
- `new_name`: new branch
- `-m new_name`: rename current
...
...
@@ -128,22 +128,7 @@ Git advantage:
- Branch can points at non-top commit
- See `git checkout`
3. `HEAD` & special pointers
- `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
3. Tag
- Still pointers!
- Difference:
- Branch/`HEAD`: move with commits
...
...
@@ -155,23 +140,49 @@ Git advantage:
git tag tag_name
# annotated - have 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
- Raw pointers are dirty -> Meet relative ref
- NO one remebers commit id
- *Even* Thanh
- `~` & `^`: back reference suffix
- Similarity:
- Go with number: `master~5`
- Chainable: `HEAD^~^`
- `~n`: Go up n
th
generation, at the first parent
- `~n`: Go up n
<sup>th</sup>
generation, at the first parent
- For dummies: Go up **ancestor**
- `~` == `~1`
- `~2`: first parent's first parent
- `^n`: Go up to the n
th
parent (if > 1 parents)
- `^n`: Go up to the n
<sup>th</sup>
parent (if > 1 parents)
- For dummies: Go up **parent**
- `^` == `^1`
- `^3`: third parent
- Equal `~` if **no** merge commit along the path
- `^2`: depends:
- Merge commit: second parent
- Otherwise: like `~2`
- Equal `~` if **not** merge commit
- Why 2 methods?
- DAG != tree
...
...
@@ -179,7 +190,6 @@ Git advantage:
graph BT
classDef master fill:#418a44;
subgraph ref_each_node_from_HEAD
C1((C1));
C2((C2)) -- "HEAD~4" --> C1;
C3((C3)) -- "HEAD~^2~~" --> C1;
...
...
@@ -191,7 +201,6 @@ Git advantage:
m("->master<-") --> C7;
class m master;
end
```
6. Refspec
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment