Skip to content

Commit 40c0b6e

Browse files
committed
add git-inside, git-cheatsheet
1 parent ab8ca3a commit 40c0b6e

File tree

4 files changed

+98
-6
lines changed

4 files changed

+98
-6
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 面试要点记录
2-
> 主要涉及到嵌入式软件开发、嵌入式驱动开发、RTOS开发、IOT开发等知识点
2+
> 主要涉及到嵌入式软件开发、嵌入式驱动开发、IOT开发、git等知识点
33
> 最新的请参考[wiki](https://github.com/xiaowenxia/embedded-notes/wiki)和我的[个人博客](https://xiaowenxia.github.io/embedded-notes/)
44
---
55
### 要点
@@ -12,6 +12,7 @@
1212
- [x] linux 多线程 多进程通讯 linux系统任务调度和中断
1313
- [ ] bash命令 shell makefile python github go javascript
1414
- [ ] linux 启动过程
15+
- [ ] git 命令
1516
---
1617
#目录
1718
* [c语言基础](./c基础.md)
@@ -64,8 +65,11 @@
6465
* [shell](./linux.md#shell)
6566
* [freertos 源码详解](./freertos-inside.md)
6667
* [协程--croutine.c](./freertos-inside.md#协程--croutine.c)
67-
* [tcpip协议栈知识点](./tcpip协议栈.md)
68+
* [tcpip 协议栈知识点](./tcpip协议栈.md)
6869
* [tcpip模型](./tcpip协议栈.md#tcpip模型)
6970
* [以太网协议](./tcpip协议栈.md#以太网协议)
7071
* [ARP协议](./tcpip协议栈.md#ARP协议)
7172
* [TCP协议](./tcpip协议栈.md#TCP协议)
73+
* [git 使用说明](./git.md)
74+
* [git cheatsheet](./git.md#git-cheatsheet)
75+
* [git 底层技术](./git-inside.md)

git-inside.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
2+
常用的 git 说明见 [git 使用说明](./git.md) 。本文记录一些底层 git 技术。
3+
4+
### clone 本地仓库
5+
```bash
6+
$ git clone /home/git/repositories/801/038/000/38801.git
7+
```
8+
9+
### 查看object文件的内容
10+
使用 `git cat-file` 可以查看 `object` 文件的内容,但是查看的内容是转换过的:
11+
12+
```bash
13+
$ git cat-file -p aa548c4d7910229712ba3a41e74c6db872e8ab64
14+
100644 blob c30106543ed8f32af334362fa82e3a4ad71ef20f home.md
15+
```
16+
17+
可以使用 [zlib-flate](http://manpages.ubuntu.com/manpages/trusty/man1/zlib-flate.1.html) 命令解压看到真实内容:
18+
19+
```bash
20+
$ zlib-flate -uncompress < .git/objects/aa/548c4d7910229712ba3a41e74c6db872e8ab64 | hexdump -C
21+
00000000 74 72 65 65 20 33 35 00 31 30 30 36 34 34 20 68 |tree 35.100644 h|
22+
00000010 6f 6d 65 2e 6d 64 00 c3 01 06 54 3e d8 f3 2a f3 |ome.md....T>..*.|
23+
00000020 34 36 2f a8 2e 3a 4a d7 1e f2 0f |46/..:J....|
24+
0000002b
25+
```
26+
27+
> tree 对象 文件格式请看:[tree 对象](https://juejin.im/post/6874840619332665357#heading-16)
28+
> 需要安装 qpdf 才能正常使用 [zlib-flate](http://manpages.ubuntu.com/manpages/trusty/man1/zlib-flate.1.html) 命令:`apt install qpdf`
29+
30+
### git cat-file
31+
查看objects文件。
32+
**说明**
33+
```bash
34+
usage: git cat-file (-t [--allow-unknown-type] | -s [--allow-unknown-type] | -e | -p | <type> | --textconv | --filters) [--path=<path>] <object>
35+
or: git cat-file (--batch | --batch-check) [--follow-symlinks] [--textconv | --filters]
36+
37+
<type> can be one of: blob, tree, commit, tag
38+
-t show object type
39+
-s show object size
40+
-e exit with zero when there's no error
41+
-p pretty-print object's content
42+
--textconv for blob objects, run textconv on object's content
43+
--filters for blob objects, run filters on object's content
44+
--path <blob> use a specific path for --textconv/--filters
45+
--allow-unknown-type allow -s and -t to work with broken/corrupt objects
46+
--buffer buffer --batch output
47+
--batch[=<format>] show info and content of objects fed from the standard input
48+
--batch-check[=<format>]
49+
show info about objects fed from the standard input
50+
--follow-symlinks follow in-tree symlinks (used with --batch or --batch-check)
51+
--batch-all-objects show all objects with --batch or --batch-check
52+
```
53+
**示例**
54+
```bash
55+
# 查看objects文件类型
56+
$ git cat-file -t 56ec1a0729533fbd8d38b7964b6f8ca2cace70ba
57+
commit
58+
59+
# 查看objects文件大小
60+
$ git cat-file -s 56ec1a0729533fbd8d38b7964b6f8ca2cace70ba
61+
243
62+
63+
# 查看objects文件(格式化)内容
64+
$ git cat-file -p 56ec1a0729533fbd8d38b7964b6f8ca2cace70ba
65+
tree 7f9adb36c3e987d1ca9d40ba538afd8cbc74e942
66+
parent cf22ff3d15d718603f93c36f13d848e00d841def
67+
author chenan.xxw <[email protected]> 1599545250 +0800
68+
committer chenan.xxw <[email protected]> 1599545250 +0800
69+
70+
update README.md
71+
72+
# 也可以通过 tag 或 branch 名称查看 object 文件
73+
$ git cat-file -t v0.1.0
74+
tag
75+
$ git cat-file -p v0.1.0
76+
object c5b97d5ae6c19d5c5df71a34c7fbeeda2479ccbc
77+
type commit
78+
tag v0.1.0
79+
tagger Scott Chacon <[email protected]> 1290556430 -0800
80+
81+
tagging initial release of libgit2
82+
```

git.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# 目录
2-
## 说明
3-
git操作笔记
1+
## git 使用说明
2+
git操作笔记,初级使用教程请参考 [git cheatsheet](#git-cheatsheet)
43

54
### 添加文件
65
```sh
@@ -70,4 +69,11 @@ git commit --amend
7069
7170
```sh
7271
git push origin HEAD:refs/changes/<change id>
73-
```
72+
```
73+
74+
## 附录
75+
76+
### git cheatsheet
77+
78+
![git cheatsheet](res/git-cheatsheet.png)
79+
> [Gitlab](http://gitlab.com/) 官方提供的 git cheatsheet 。

res/git-cheatsheet.png

1.11 MB
Loading

0 commit comments

Comments
 (0)