Git命令大全
基础命令
- git init:初始化一个Git仓库
- git add <file>:将文件添加到暂存区
- git commit -m "<message>":提交暂存区的文件到本地仓库
- git status:查看工作区、暂存区、本地仓库的状态
- git log:查看提交历史
- git diff:查看工作区和暂存区的差异
分支管理
- git branch:查看本地分支
- git branch <branch-name>:创建新分支
- git checkout <branch-name>:切换分支
- git merge <branch-name>:合并指定分支到当前分支
- git branch -d <branch-name>:删除指定分支
远程仓库
- git remote add <remote-name> <remote-url>:添加远程仓库
- git push <remote-name> <branch-name>:将本地仓库的指定分支推送到远程仓库
- git pull <remote-name> <branch-name>:将远程仓库的指定分支拉取到本地仓库
- git clone <remote-url>:克隆远程仓库到本地
其他命令
- git stash:将当前工作区的修改暂存起来
- git tag <tag-name>:打标签
- git reset <commit>:回退到指定的提交
- git revert <commit>:撤销指定的提交
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。