Skip to content

5. git常用操作

bash
# git拉取所有分支
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done && git fetch --all && git pull --all


#更新远程仓库地址
git remote set-url origin url
# 列出仍在远程跟踪但是远程已被删除的无用分支,上面例子此处应输出  '* [将删除] origin/a',不执行删除操作
git remote prune origin --dry-run
 # 清除上面命令列出来分支的远程跟踪,输出 '* [已删除] origin/a'
git remote prune origin

# 查看远程仓库地址
git remote -v

# 忽略换行和文件权限
git config core.filemode false
git config --global core.autocrlf false

# git 打补丁
git apply --stat patchfile
git apply --check patchfile
git apply patchfile