用户工具

站点工具


git

这是本文档旧的修订版!


cherry pick

阮一峰的教程

# 单个提交
git cherry-pick <commitHash>
# 连续多个提交
git cherry-pick <HashA> <HashB>

submodule

Git 工具 - 子模块

  • 数字列表项目子模块的配置文件:repo主目录下的 .gitmodules(不建议直接改这个文件)
# 创建一个子模块
git submodule add git@gitlab.xxx.com:A/B.git
# 创建一个子模块并指定分支和路径
git submodule add -b feature/test001 -- "git@gitlab.xxx.com:A/B.git" "yyy/zzz/B"

# 更新子模块(子模块的内容切换为外部 repo 记录的 hash 号)
git submodule update --init --recursive
# 更新子模块(子模块的内容为对应分支上的最新提交)
git submodule update --init --recursive --remote

# 列出所有子模块
git submodule

压缩commit

修改用户名和邮箱

Git 工具 - 重写历史

// 设置全局
git config --global user.name "Author Name"
git config --global user.email "Author Email"

// 或者设置本地项目库配置
git config user.name "Author Name"
git config user.email "Author Email"

// 修改最近一次提交的用户信息
git commit --amend --author="NewAuthor <NewEmail@address.com>"

回退到某个版本

git reset --hard fae6966548e3ae76cfa7f38a461c438cf75ba965
git.1606311074.txt.gz · 最后更改: 2020/11/25 21:31 由 plough

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki