or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
| Syntax | Example | Reference | |
|---|---|---|---|
| # Header | Header | 基本排版 | |
| - Unordered List |
|
||
| 1. Ordered List |
|
||
| - [ ] Todo List |
|
||
| > Blockquote | Blockquote |
||
| **Bold font** | Bold font | ||
| *Italics font* | Italics font | ||
| ~~Strikethrough~~ | |||
| 19^th^ | 19th | ||
| H~2~O | H2O | ||
| ++Inserted text++ | Inserted text | ||
| ==Marked text== | Marked text | ||
| [link text](https:// "title") | Link | ||
|  | Image | ||
| `Code` | Code |
在筆記中貼入程式碼 | |
| ```javascript var i = 0; ``` |
|
||
| :smile: | ![]() |
Emoji list | |
| {%youtube youtube_id %} | Externals | ||
| $L^aT_eX$ | LaTeX | ||
| :::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx-
Any changes
Be notified of any changes
-
Mention me
Be notified of mention me
-
Unsubscribe
SubscribeIntroduction to Git –- Fall 2023
Lecture 3: Basic concepts
Slides: https://hackmd.io/@git-fall-2023/L3-concepts#/
Remark
What is Git?
Why use Git?
How does Git store the history?
What is inside a repository?
Most directories are empty and the files are not that interesting:
Let's add some content:
Working tree
repository/is a part of the working tree (or the workspace)..git/is not included.file.txt.git addandgit commitcommands tell Git to care aboutfile.txt.Objects
.git/objects/.Let's take a second look at the repository:
What are these two other objects?
Trees
In this case, the tree has one level and one blob:
Let's take a third look at the repository:
Just one object remains…
Commits
A commit stores the state of the project in a given point of time.
In this case, the commit points to a tree that has one level and one blob:
In a more general case, the associated tree can contain several levels and multiple blobs:
Working with Git
Let's see what else we can find…
HEAD and other references
HEADpoints (indirectly) to23b3ed5b1:HEADandmasterare references.HEADdetermines "most recent" commit.HEAD.masteris the current branch (more later).Index (staging area)
Let's repeat some of the earlier steps:
git addcommand creates a blob that correspond to the updatefile.txtfile.The index is a binary file:
We can now turn the index to the next commit:
Parent
Commit tree
HEAD and other references (again)
HEADandmaster:HEAD.HEADto something else:Branches
parentpoints to the first commit:We can give the second branch a name:
Merging
We can merge the two branches together:
We fix some conflicts at this point…
The created commit has two parents:
Finally, the tree looks like follows:
Switching to a specific commit
We can always move back to any of the previous commits:
The end.
An idea: Try to play with different commands. See what happens to the
.git/directory.