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]
相关推荐
潘晓可25 分钟前
从自建Github实例迁移仓库到SaaS版Github
github
极客小云37 分钟前
【基于AI的自动商品试用系统:不仅仅是虚拟试衣!】
javascript·python·django·flask·github·pyqt·fastapi
念丶小宇14 小时前
Github上传大文件
github
极智-99618 小时前
GitHub 热榜项目-日榜精选(2026-02-03)| AI智能体、终端工具、RAG技术等 | claude-mem、99、termux-app等
人工智能·网络安全·github·ai智能体·llm应用·rag技术·torrent工具
骂我的人都死了19 小时前
DevOps架构部署
运维·ubuntu·docker·k8s·github·devops·python3.11
Alaaaaaaan19 小时前
[DevOps]使用github-action工具部署docker容器(实现提交代码一键推送部署到服务器)
服务器·前端·docker·容器·github
CryptoRzz20 小时前
德国股票数据 API 对接实战(DAX 指数与实时行情)
websocket·区块链·github·分布式账本
Tipriest_20 小时前
GitHub Gist 功能详解:从入门到进阶
github·gist
困惑阿三21 小时前
CloudflarePages+GitHub零成本博客搭建手册
github
猫头虎1 天前
2026全网最热Claude Skills工具箱,GitHub上最受欢迎的7大Skills开源AI技能库
langchain·开源·prompt·github·aigc·ai编程·agi