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]
相关推荐
逛逛GitHub2 小时前
7 个最近 GitHub 上火火火的开源项目,推荐一哈。
github
__雨夜星辰__3 小时前
什么是 Git 与 Git※hub(※Git※hub加※速访※问教程)
git·github
子夜江寒3 小时前
GitHub入门协作
github
逛逛GitHub4 小时前
一个运维人写了 12 年的开源项目,Star 刚刚破了 3 万。
github
daguanren5 小时前
LMRing 实测榜:GPT-5.4 登顶?Claude 4.6 还能打吗?
github·aigc
CoovallyAIHub5 小时前
Claude Code Review:多 Agent 自动审查 PR,代码产出翻倍后谁来把关?
算法·架构·github
happyprince8 小时前
2026年03月27日热门Model/github项目
github
司南-70499 小时前
开发自己的app之 - 如何构建自己github的release仓库
electron·github·web app
0xCode 小新10 小时前
Git常用操作
git·gitee·github
MicrosoftReactor10 小时前
技术速递|如何使用 GitHub Security Lab 的开源 AI 驱动框架进行漏洞扫描
人工智能·安全·开源·github·漏洞扫描