Git 常用命令合集
水一篇文章哈哈
git config user.name
: 配置当前仓库提交更改用户名
git config user.email
: 配置当前仓库提交更改邮箱
git config --global user.name
: 配置全局提交更改用户名
git config --global user.email
: 配置全局提交更改邮箱
git clone
: 拉取远程仓库
git clone -b "branch name"
: 拉取远程仓库的指定分区
git clone --depth=1
: 仅拉取最小仓库
git init
: 在当前目录初始化 Git
git add
: 添加到暂存区,以便提交更改
git add .
: 添加当前所有文件到暂存区,以便提交更改
git commit
: 打开默认文本编辑器,来编辑提交信息
git commit -m "your commit"
: 不打开文本编辑器,来编辑提交信息
git commit --amend
: 修改上个 commit 信息
git push
: 将仓库上传到远程仓库
git cherry-pick
: pick 其它提交提交到当前仓库
git branch
: 查看当前分支
git branch -m
: 修改当前分支名
git remote
: 查看当前仓库名
git remote add "name" "link"
: 添加远程仓库
git remote update
: 从远程仓库更新本地仓库
git merge
: 合并提交
git fetch
: 临时拉取远程仓库
git status
: 查看当前仓库状态
git diff
: 查看当前文件修改状态
git log
: 查看提交历史
git reset --hard "commit id"
: 重置仓库到某 commit
git revert
: 反转一个提交
git config --global https.proxy
: 设置 https 代理
git config --global https.proxy
: 设置 http 代理