Skip to content

Commit

Permalink
feat: update notes about git-filter-repo
Browse files Browse the repository at this point in the history
  • Loading branch information
WTIFS committed Apr 29, 2024
1 parent 45900e0 commit 75a35f7
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Go/1.语言基础/4.调试.md
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ type StringHeader struct {
"/Users/xxx/Library/Application Support/JetBrains/IntelliJIdea2023.1/plugins/go-plugin/lib/dlv/macarm/dlv" --listen=127.0.0.1:51683 --headless=true --api-version=2 --check-go-version=false --only-same-user=false exec /Users/xxx/Library/Caches/JetBrains/IntelliJIdea2023.1/tmp/GoLand/___go_build_github_com_WTIFS_project_diva_src_myGo --
```
其中的 `--listen` 参数表示将 dlv 作为一个服务启动,可通过其后面指定的地址交互。这样可以在生产环境机器上启动 dlv,然后在 IDE 的 debugger 里配置这个地址,就可以远程 debug、短点调试了
其中的 `--listen` 参数表示将 dlv 作为一个服务启动,可通过其后面指定的地址交互。这样可以在生产环境机器上启动 dlv,然后在 IDE 的 debugger 里配置这个地址,就可以远程 debug、断点调试了
在 IDE 里新建远程配置,然后按提示在远端机器上安装好 dlv 环境后 执行如下命令:
Expand Down
2 changes: 1 addition & 1 deletion Go/3.数据结构/2.切片slice.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (s *state) expr(n *Node) *ssa.Value {

## append追加

`append` 目前的源码是在编译期间生成的,中间代码生成阶段可见 [`cmd/compile/internal/gc.state.append`](https://draveness.me/golang/tree/cmd/compile/internal/gc.state.append) 方法。
`append` 目前的源码是在编译期间生成的,中间代码生成阶段可见 [`cmd/compile/internal/gc.state.append`](https://github.com/golang/go/blob/ac0ba6707c1655ea4316b41d06571a0303cc60eb/src/cmd/compile/internal/gc/ssa.go#L2841) 方法。

`slice = append(slice, 1, 2, 3)` 为例:我们会先解构切片结构体获取它的数组指针、大小和容量。如果在追加元素后切片的大小大于容量,那么就会调用 [`runtime.growslice`](https://draveness.me/golang/tree/runtime.growslice) 对切片进行扩容并将新的元素依次加入切片。否则直接对底层数组赋值。

Expand Down
4 changes: 4 additions & 0 deletions Network/TCP三次握手.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@

#### 为什么需要三次握手





弄清这个问题,我们需要先弄明白三次握手的目的是什么,能不能只用两次握手来达到同样的目的。

三次握手的目的是建立**可靠**的连接,两次握手无法达到这个目的。
Expand Down
62 changes: 62 additions & 0 deletions Work/git-filter-repo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# gitlab 代码仓库瘦身



# 安装 git-filter-repo

`yum` 安装:

```
yum install git-filter-repo
```

或者直接从 github 上下载:

```go
https://github.com/newren/git-filter-repo/blob/main/git-filter-repo
```



# 从存储库历史记录中清除文件

1. gitlab - Settings - General - Advanced - Export 导出并下载项目

2. 使用 `tar` 解压缩备份:

```go
mkdir tmp
mv project-backup.tar.gz tmp/
cd tmp
tar xzf project-backup.tar.gz
cd project.git
```

3. 使用 `--bare``--mirror` 选项从包中克隆存储库的新副本:

```shell
git clone --bare --mirror project.bundle
```

4. 清除所有大于10M的文件

```go
git-filter-repo --strip-blobs-bigger-than 10M
```

5. 由于从捆绑文件克隆会将 `origin` 远程设置为本地捆绑文件,因此请删除此 `origin` 远程,并将其设置为存储库的 URL:

```go
git remote remove origin
git remote add origin https://gitlab.example.com/<namespace>/<project_name>.git
```

6. 强制推送更改以覆盖 GitLab 上的所有分支:

```shell
git push origin --force 'refs/heads/*'
git push origin --force 'refs/tags/*'
git push origin --force 'refs/replace/*'
```

7. 运行存储库清理:前面执行 `git-filter-repo` 命令后,会在 `filter-repo` 文件夹下生成一个 `commit-map` 文件,用于标识可清理的文件,将该文件上传至 gitlab-Settings-Repository-Repository cleanup 里,然后 gitlab 就会释放空间了
19 changes: 10 additions & 9 deletions Work/golang.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
gomonkey 不支持 Mac M2 芯片:使用如下方法运行测试:

```bash
GOARCH=amd64 go test -exec='arch -x86_64' -gcflags='-N -l' -run XXX
```



##### gomod replace

[【Go mod 学习之 replace 篇】解决 go 本地依赖、无法拉取依赖、禁止依赖等问题](https://blog.csdn.net/qq_24433609/article/details/127323097)
Expand All @@ -29,8 +21,17 @@ pip install diff_cover
go install github.com/axw/gocov/gocov@latest
go install github.com/AlekSi/gocov-xml@latest

go test -gcflags "all=-N -l" -v ./... -coverprofile=cover.out
go test -gcflags "all=-N -l" ./... -coverprofile=cover.out
gocov convert cover.out | gocov-xml > coverage.xml
diff-cover coverage.xml --compare-branch=master --html-report report.html
# 打开 report.xml
```



查看全量具体哪些行

```go
go tool cover -html=coverage.out
```

1 change: 0 additions & 1 deletion Work/mysql命令.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ mysqldump -u 用户名 -p 密码 数据库名 表名 > 文件名
# 导入
mysqldump -u 用户名 -p 密码 数据库名 < 文件名
```

0 comments on commit 75a35f7

Please sign in to comment.