全局设置
git config --global user.name “Your Name”
git config --global user.email "email@example.com"
初始化 Git 仓库
git init
添加修改到暂存区
git add …
提交修改
git commit -m
查看工作区状态
git status
查看已修改未暂存的内容
git diff …
查看已暂存的内容
git diff --staged …
查看提交历史, 加上 -p 参数显示每次提交的内容差异
git log [-p]
重新提交
git commit --amend [-m ]
取消暂存(暂存区向 Git 仓库同步)
git reset HEAD …
放弃工作目录中的修改(工作目录向暂存区同步)
git checkout – …
克隆现有的仓库
git clone
从远程仓库拉取(通常会从最初克隆的服务器上抓取数据并自动尝试合并到当前所在的分支)
git pull
推送到远程仓库
git push [remote-name] [branch-name]
创建分支
git branch
切换分支
git checkout
创建并切换到新分支
git checkout -b
合并其它分支的内容到当前分支
git merge
删除分支
git branch -d
储藏暂存区
git stash
查看所有暂存内容
git stash list
应用储藏的暂存区内容
git stash apply []
删除储藏的暂存内容
git stash drop
应用并删除地一个暂存内容
git stash pop
git常用命令
最新推荐文章于 2023-05-17 22:28:20 发布