GitHub常用命令

GitHub常用命令

远程仓库相关命令

拉取项目到本地

shell 复制代码
git clone [url]

拉取远程仓库

shell 复制代码
git pull [remoteName] [localBranchName]

推送远程仓库

shell 复制代码
git push [remoteName] [localBranchName]

分支操作相关命令

查看所有本地分支

shell 复制代码
git branch

查看所有远程分支

shell 复制代码
git branch -r

查看所有本地分支和远程分支

shell 复制代码
git branch -a

切换分支

shell 复制代码
git checkout [分支名称]

创建本地分支

shell 复制代码
//注意:新分支创建后不会自动切换为当前分支
git branch name

创建远程分支(本地分支push到远程)

shell 复制代码
git push origin [分支名称]

创建新分支并切换到新分支

shell 复制代码
git checkout -b  [分支名称]

合并指定分支到当前分支

shell 复制代码
git merge [分支名称]

删除分支

shell 复制代码
git branch -d [分支名称]

代码提交相关命令

提交至暂存区

shell 复制代码
git stash save [message]

恢复暂存区代码

shell 复制代码
git stash apply

提交暂存区到仓库区

shell 复制代码
git commit -m [message]

查看信息

显示有变更的文件

shell 复制代码
git status

显示当前分支的版本历史

shell 复制代码
git log

显示commit历史

shell 复制代码
git log --stat

版本(tag)操作相关命令

创建版本

shell 复制代码
git tag [name]

查看所有版本

shell 复制代码
git tag

查看tag信息

shell 复制代码
git show [tag]

删除本地版本

shell 复制代码
git tag -d [name]
相关推荐
天天扭码8 小时前
在React项目中实现富文本编辑文章并发布
前端·react.js·github
蜡笔小新..9 小时前
Github上一些使用技巧(缩写、Issue的Highlight)自用
github·issue
colorful_stars13 小时前
vscode连接的linux服务器,上传项目至github
linux·vscode·github
金木讲编程17 小时前
GitHub Copilot 使用手册与原理解析
github·copilot·ai编程
qianmoQ1 天前
GitHub 趋势日报 (2025年05月23日)
github
七灵微1 天前
【GitHub Pages】部署指南
github
油泼辣子多加1 天前
2025年05月28日Github流行趋势
github
waterHBO1 天前
python 小工具,获取 github 仓库信息
开发语言·python·github
@comefly2 天前
本地github ssh多账号问题
运维·ssh·github
摸鱼的后端2 天前
开源软件协议大白话分类指南
github·开源软件