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
Introduction to Git –- Fall 2021
Lecture 2: Basic concepts
Slides: https://hackmd.io/@hpc2n-git-2021/L2-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:
Lets add some content:
Working tree
repository/
is a part of the working tree (or the workspace)..git/
is not included.file.txt
.git add
andgit commit
commands 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
HEAD
points (indirectly) to23b3ed5b1
:HEAD
andmaster
are references.HEAD
determines "most recent" commit.HEAD
.master
is the current branch (more later).Index (staging area)
Let's repeat some of the earlier steps:
git add
command creates a blob that correspond to the updatefile.txt
file.The index is a binary file:
We can now turn the index to the next commit:
Parent
Commit tree
HEAD and other references (again)
HEAD
andmaster
:HEAD
.HEAD
to something else:Branches
parent
points to the first commit:We can give the second brach 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.
And idea: Try to play with different commands. See what happens to the
.git/
directory.