Skip to content

Commit 76fb192

Browse files
authored
Merge pull request #6 from lec-org/sy_new
sync
2 parents 657231f + 2cd9611 commit 76fb192

File tree

4 files changed

+90
-20
lines changed

4 files changed

+90
-20
lines changed

Git.md

+53-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Git备忘录
22

3-
d6d004898587a25b023e83658c803d3e745e0b03c005a36765a78a2f9abf8b5ffdacc72fea1982a1c19f73cab2cd638c552c277fa3aff054a04bc0b09a741ec9
43

54
## 引入
65

@@ -74,7 +73,7 @@ git config --global --unset https.proxy
7473
---
7574
## Git 分支和远程操作指南
7675

77-
## git clone
76+
### git clone
7877

7978
把项目拉下来,~~这是最好用的命令~~
8079

@@ -86,64 +85,64 @@ git config --global --unset https.proxy
8685
- **查看本地分支**
8786

8887
```bash
89-
git branch
88+
git branch
9089
```
9190

92-
显示本地所有分支。
91+
显示本地所有分支。
9392

9493
- **创建新分支**
9594

9695
```bash
97-
git branch <branch-name>
96+
git branch <branch-name>
9897
```
9998

100-
创建一个名为 `<branch-name>` 的新分支。
99+
创建一个名为 `<branch-name>` 的新分支。
101100

102101
```bash
103102
git checkout --orphan <branch-name>
104103
```
105-
创建一个孤立的,没有任何commit记录的分支
106104

105+
创建一个孤立的,没有任何commit记录的分支
107106

108107
- **切换分支**
109108

110109
```bash
111-
git checkout <branch-name>
110+
git checkout <branch-name>
112111
```
113112

114-
切换到名为 `<branch-name>` 的分支。
113+
切换到名为 `<branch-name>` 的分支。
115114

116115
- **创建并切换到新分支**
117116

118117
```bash
119-
git checkout -b <branch-name>
118+
git checkout -b <branch-name>
120119
```
121120

122-
创建一个新分支并立即切换到该分支。
121+
创建一个新分支并立即切换到该分支。
123122

124123
- **删除分支**
125124

126125
```bash
127-
git branch -d <branch-name>
126+
git branch -d <branch-name>
128127
```
129128

130-
删除名为 `<branch-name>` 的分支。
129+
删除名为 `<branch-name>` 的分支。
131130

132131
- **强制删除分支**
133132

134133
```bash
135-
git branch -D <branch-name>
134+
git branch -D <branch-name>
136135
```
137136

138-
强制删除名为 `<branch-name>` 的分支,即使该分支有未合并的更改。
137+
强制删除名为 `<branch-name>` 的分支,即使该分支有未合并的更改。
139138

140139
- **重命名分支**
141140

142141
```bash
143-
git branch -m <new-branch-name>
142+
git branch -m <new-branch-name>
144143
```
145144

146-
将当前分支重命名为 `<new-branch-name>`。
145+
将当前分支重命名为 `<new-branch-name>`
147146

148147
- **合并分支**
149148

@@ -315,7 +314,7 @@ git branch -r
315314
git checkout -b <local-branch-name> <remote-name>/<remote-branch-name>
316315
```
317316

318-
从远程仓库 `<remote-name>` 的 `<remote-branch-name>` 分支拉取更新,并创建一个名为 `<local-branch-name>` 的本地分支。
317+
从远程仓库 `<remote-name>``<remote-branch-name>` 分支拉取更新,并创建一个名为 `<local-branch-name>` 的本地分支。
319318

320319

321320
如果你想同时查看本地和远程的所有分支,可以使用 `git branch -a` 命令
@@ -687,7 +686,6 @@ https://www.cnblogs.com/FraserYu/p/11192840.html
687686
---
688687

689688
### 子模块相关命令
690-
691689
- **添加子模块**
692690

693691
```bash
@@ -773,6 +771,42 @@ https://www.cnblogs.com/FraserYu/p/11192840.html
773771

774772
遍历所有子模块并更新到最新提交。
775773

774+
对于子模块,如何在不删除的情况下把子模块转换为正常的文件夹来管理?
775+
[[git把子模块文件夹转化为普通文件夹]]
776+
777+
### 删库或清空所有提交
778+
779+
先随便创建一个孤儿分支,假设名字是aa
780+
```bash
781+
git checkout --orphan aa
782+
```
783+
784+
把所有文件提交到这个分支上
785+
```bash
786+
git add .
787+
git commit -m 'clean'
788+
```
789+
790+
强制删除主分支
791+
```bash
792+
git branch -D master
793+
```
794+
795+
重命名当前分支
796+
```bash
797+
git branch -m master
798+
```
799+
800+
强制推送到远程
801+
```bash
802+
git push -f -u origin master
803+
```
804+
805+
可以部署成自动化脚本
806+
你会发现远程只有一个commit记录了
807+
808+
删库是一样的道理
809+
776810

777811
## 使用Git自动同步Obsidian配置及仓库
778812

杂类知识/Git如何push大文件.md

+25-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ git add .
3131

3232
之后不需要任何特殊操作,正常commit和push即可
3333

34+
3435
> note:glfs能免费管理的文件大小有限,只有1GB,多了要收费
3536
3637
![[Pasted image 20240902214746.png]]
@@ -47,4 +48,27 @@ git lfs pull
4748
```
4849

4950

50-
速度很快(*在解决了速度慢的问题后*)
51+
速度很快(*在解决了速度慢的问题后*)
52+
53+
# 取消GLF的托管,使之变成正常仓库
54+
55+
由于空间有限,所以有些时候我们可能会涉及到一些让由GLF托管的仓库变为正常仓库的操作。
56+
57+
> 这里再次澄清:
58+
> - GLF托管:大文件服务管理,无法直接下载或clone使用,需要用GLF拉下来或者转换
59+
> - 正常仓库:可以直接下载或clone,不支持100MB以上的文件
60+
61+
把GLF变为正常仓库的操作步骤:
62+
*此步骤可以保证有效,但是是否有其他有效的方法还尚未验证*
63+
64+
- **clone仓库**
65+
*此时文件都是占位符*
66+
- **使用 `git lfs fetch`**: 这个命令会从远程仓库下载所有的 LFS 文件,但不会自动替换本地的占位符文件。
67+
- **使用 `git lfs checkout`**: 这一步会将下载的 LFS 文件替换为实际的文件。
68+
- **取消对 LFS 文件的跟踪**: 取消对特定文件格式的 LFS 跟踪:
69+
```bash
70+
git lfs untrack "*.psd"
71+
git lfs untrack "*" # 所有文件
72+
```
73+
- **更新 `.gitattributes` 文件**: 确保 `.gitattributes` 文件不再包含 LFS 的相关条目。或者直接删除此文件
74+
- **提交更改并推送到远程**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
假如仓库中有一个或多个文件夹是以子模块的形式存在的,我们想改变这种情况,即把该文件夹当做普通文件夹处理,步骤如下:
3+
4+
- 删除仓库根目录下`.gitmodules`文件内相应的子模块信息,如果你想转换所有子模块为普通文件夹,则直接删掉`.gitmodules`文件即可
5+
- 进入仓库中的**子模块文件夹**中,删除**子模块文件夹**中的`.git`文件
6+
- 删除仓库对子模块的引用
7+
```bash
8+
git rm --cached submodule_path # 删除指向submodule的引用
9+
```
10+
- 正常add、commit、push即可,发现远程仓库对应的文件夹已不是子模块形式
11+
12+
可以搞成自动化脚本

0 commit comments

Comments
 (0)