Skip to Content
Welcome to yujie-code-blogs build by Nextra 4.0 🎉
Git

Git 指令大全

基础配置

git config --global user.name "your name" git config --global user.email "your email"

克隆仓库

git clone <repository url>

分支

切换分支

git checkout <branch name>

创建分支

git branch <branch name>

合并分支

git merge <branch name>

删除分支

git branch -d <branch name>

显示当前分支

git branch

显示所有分支

git branch -a

远程仓库

显示远程仓库

git remote -v

添加远程仓库

git remote add origin <repository url>

推送代码到远程仓库

git push origin <branch name>

拉取代码到本地仓库

git pull origin <branch name>

查看状态

git status

查看提交记录

git log

撤销上一次提交

git reset --hard HEAD^

撤销所有提交

git reset --hard origin/master

回退到指定版本

git reset --hard <commit id>