karmi (owner)

Revisions

gist: 202925 Download_button fork
public
Public Clone URL: git://gist.github.com/202925.git
Embed All Files: show embed
01__hello_git_objects.sh #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# =====================
# = Hello Git Objects =
# =====================
 
# Creates basic Git repository with one file to show how Git stores and tracks content
 
# Create new folder for repository
mkdir hello_git_objects
cd hello_git_objects
 
# Initialize Git repository inside
git init
 
# ---
 
tree .git
 
# ---
 
# Add some content
echo "Hello, World" > file.txt
cat file.txt
 
# ---
 
# Show repository status
git status
 
# ---
 
# Add file to index and show status
git add file.txt
git status
 
# ---
 
# Commit the staged file
git commit -m "Initial commit"
 
# ---
 
# Show revision log
git log --stat
 
# ---
 
# Create a tag in repository from last revision
git tag -a v.0.1 -m "First version"
 
# ---
 
# Let's inspect the repository "raw" contents a little bit
tree .git/objects
# ---
find .git/objects -type f
 
# ---
 
# Let's have a look what we have here
# Starting with the commit
echo "Last revision ID is" $(git log --format="%H" -1)
 
git cat-file -p $(git log --format="%H" -1)
 
# ---
 
# Let's have a look at the tree
git cat-file -p 76bf39ab0db46b183b49d9f707d86e580f78e932
 
# ---
 
# Let's have a look at the blob
git show 3fa0d4b98289a95a7cd3a45c9545e622718f8d2b
 
# ---
 
# And finally at the tag
git show v.0.1