git 操作清单

git 命令

1、大文件管理

git lfs install
git lfs track "*.dll"

2、换行符转换禁用

git config --global core.autocrlf false

3.创建空白分支

git checkout --orphan 

4.更换远程仓库地址

git remote set-url origin ssh地址/https地址

5.增加子仓库配置

git submodule add -b 子仓库分支(develop) 子仓库地址(git@gitlab.com:XXXX/sub.git) 主仓库中的子仓库目录路径(ThirdParty)

6.克隆/切换分支同步拉取子仓库

git clone --recurse-submodules git@gitXXX.com
git checkout branch_name --recurse-submodules 

7.主仓库中仅拉取/更新子仓库命令

git submodule update --remote --recursive

8.git代理端口操作

git config --global http.proxy "http://127.0.0.1:7890"
git config --global https.proxy "http://127.0.0.1:7890"

git config --global --unset http.proxy
git config --global --unset https.proxy

9.换行符

git config --global core.autocrlf true/input/false

若仓库合并代码出现换行符冲突或更改等问题,可配置正确的换行符策略后对整个仓库的文本文件进行换行符格式化。如配置提交为lf,本地检出为crlf后。执行命令:

git add --renormalize .

具体配置和问题解决可参考:配置 Git 处理行结束符

配置文件

1、忽略提交

# ---> C++
# build
cmake-build-debug/
cmake-build-release/

# JetBrains
.idea/

# doc
.def

# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
posted @ 2025-12-27 17:43  愤怒的蒲公英  阅读(2)  评论(0)    收藏  举报