Skip to content

其它命令 ​

git-https-跳过验证的方法 ​

bash
git config --global http.ssLVerify "false"

Git 的配置命令,用于读取 / 设置 Git 的全局 / 本地配置项 ​

bash
git config

查看全局用户名 ​

bash
git config --global user.name

查看全局邮箱 ​

bash
git config --global user.email

查看当前仓库的用户名(若没设置,会显示全局配置) ​

bash
git config user.name

查看所有配置(包含 name/email 及其他) ​

bash
git config --list

查看提交记录 ​

bash
git log

查看本地所有分支(* 标记当前分支) ​

bash
git branch

创建分支 ​

bash
git branch 分支名

查看本地+远程所有分支 ​

bash
git branch -a

查看分支详细信息(最后提交、关联远程等) ​

bash
git branch -vv

切换已存在的分支 ​

bash
旧版写法
git checkout 分支名

新版 Git(2.23+)推荐写法,更直观
git switch 分支名

删除本地已合并的分支(安全) ​

bash
git branch -d 分支名

强制删除本地未合并的分支(谨慎,会丢失未合并的修改) ​

bash
git branch -D 分支名

将当前分支重命名 ​

bash
git branch -m 新分支名

将指定分支重命名 ​

bash
git branch -m 旧分支名 新分支名

取消本地 master 分支与远程 origin/master 的关联 ​

bash
git branch --unset-upstream master

方式1:HTTPS 地址(无需配置密钥,每次推送需输账号密码) ​

bash
git remote add origin https://github.com/你的用户名/仓库名.git

方式2:SSH 地址(需配置 SSH 密钥,免密推送,推荐) ​

bash
git remote add origin git@github.com:你的用户名/仓库名.git

Copyright © 2026 Luke