Git命令笔记
2020/11/6...大约 1 分钟
摘要
记录自己用过的Git命令
配置命令
提示
如果需要全局设置,在 config 后加 --global
- 设置名字:
git config user.name "name" - 设置邮箱:
git config user.email "email" - 永久记住密码:
git config credential.helper store - 记住15分钟:
git config credential.helper cache - 记住1小时:
git config credential.helper 'cache –timeout=3600' - 设置http代理:
git config --global http.proxy 'socks5://127.0.0.1:7890' - 设置https代理:
git config --global https.proxy 'socks5://127.0.0.1:7890' - 使用密钥对 commit 进行签名:
git config user.signingkey <密钥ID> - 设置 Git 使用该密钥加密 commit:
git config commit.gpgsign true - 设置 Git 全局使用该密钥加密 tag:
git config tag.forcesignannotated true
操作命令
- 查看所有分支:
git branch -a - 查看远程分支:
git branch -r - 查看本地分支:
git branch
提示
在git远程删除分支后,本地使用 git branch -a 后还是能看到已经删除的分支
就得用下面的两条命令来删除那些远程仓库不存在的分支
- 查看远程分支,本地分支与之相对应关系等信息:
git remote show origin - 删除了那些远程仓库不存在的分支:
git remote prune origin
