git 有用的命令
- 指定标签创建分支
git checkout -b 分支名 tagname
- 基于远程分支创建
git checkout -b 分支名 origin/远程分支名
- 指定提交创建分支
git checkout -b 分支名 commitid
- 克隆仓库目录
git clone --bare [旧仓库地址]
- 推送克隆的仓库
git push --mirror [新仓库地址]
# 配合上面的 clone --bare 可以实现库的迁移
- 其他
忽略https校验
git config --global http.sslVerify false
解决GIT提交,文件名太长问题(filename too long)
git config --system core.longpaths true
暂时忽略文件
git update-index --assume-unchanged '文件路径'
git update-index --no-assume-unchanged '文件路径'
导出指定开发者提交的记录
git log --author="John Doe" --since="2023-09-01" --until="2023-09-30" --pretty=format:"%h - %s (%ad)" --date=short > john_doe_september_commits.txt
子模块初始化
git submodule update --init --recursive
# 子模块初始化并拉取最新代码
git submodule update --recursive --remote
git 加速访问
- 访问 https://sites.ipaddress.com/github.com/
- 往下拉
- 更新源
git remote prune origin
执行 git remote prune origin 将检查你的本地仓库与远程仓库的状态,并移除本地仓库中不存在于远程仓库的分支的引用。这样可以保持你的本地仓库与远程仓库同步。
否则有如下报错:
error: cannot lock ref 'refs/remotes/origin/dev':
修改host文件
C:\Windows\System32\drivers\etc\hosts