git 操作大全

克隆仓库

复制代码
git clone 仓库地址

克隆仓库指定分支

复制代码
git clone -b 分支名 --single-branch 仓库地址

查看远程所有分支

复制代码
git branch -a

查看当前本地的分支

复制代码
git branch

切换分支

如果是第一次拉取或者创建项目,使用

复制代码
git checkout -b 本地分支name 远程分支name

比如:

git checkout -b dev origin/dev

切换分支

如果本地已存在两个分支,使用

复制代码
git checkout  本地分支name 远程分支name

比如:

git checkout  dev origin/dev

清除未跟踪的文件

错误:工作区中下列未跟踪的文件将会因为检出操作而被覆盖:

.DS_Store

请在切换分支前移动或删除。

正在终止

复制代码
git clean -f
相关推荐
爱学英语的程序员1 小时前
Git 提交 LF will be replaced by CRLF the next time Git touches it 报错
git
qq_339191142 小时前
服务器git pull每次都要输入密码,linux 设置git登录,linux设置git只输入一次账户密码
git
一颗小行星!8 小时前
快速理解 Git submodule
git
A-Jie-Y10 小时前
Git基础-核心概念与常用命令
git
夜珀11 小时前
Git基础修炼手册:在AtomGit上玩转版本控制
git
golang学习记11 小时前
Zed IDE官宣新招:Git Graph 正式支持!
ide·git
要记得喝水11 小时前
适用于 Git Bash 的脚本,批量提交和推送多个仓库的修改
git·elasticsearch·bash
AI_Claude_code12 小时前
专栏导论:开源项目贡献的价值与Git工作流全景图
git·开源
never forget shyang12 小时前
CCS20.2.0使用教程
c语言·git·单片机
lifewange21 小时前
常用的Git命令有哪些?
git