git-工作场景

1. 远程分支为准

强制切换到远程分支并忽略本地未提交的修改

复制代码
git fetch origin     # 获取最新的远程分支信息
git reset --hard origin/feature_server_env_debug_20240604   # 强制切换到远程分支,并忽略本地修改

2. 切换分支

  1. **查看所有分支:**

git branch

  1. **创建并切换到新分支:**

git checkout -b <branch_name>

  1. **切换到已存在的分支:**

git checkout <branch_name>

  1. **切换到上一个分支(切换到最近一次所在的分支):**

git checkout -

  1. **切换到远程分支:**

git checkout -b <local_branch_name> origin/<remote_branch_name>

  1. **删除分支:**

git branch -d <branch_name>

  1. **强制删除分支(未合并时使用):**

git branch -D <branch_name>

相关推荐
嘻嘻仙人3 小时前
Ubuntu中 git上传自己的项目和二次上传一般流程
git·github
Patrick_Wilson4 小时前
Squash Merge 的血缘陷阱:为什么删掉的代码又活了过来
前端·git·程序员
沉浸学习的匿名网友6 小时前
什么是 .gitignore?为什么每个 Git 项目几乎都离不开它?
前端·git
深海鱼在掘金1 天前
Git 完全指南 —— 第3章:理解工作区、暂存区、版本库三个核心
git
江华森1 天前
Git 基础筑基:从原理到团队协作的全栈实战
git
JakeJiang1 天前
Git 必备命令指南:从日常高频到项目开发实战
git
叫我少年2 天前
Windows 中安装 git
git
深海鱼在掘金7 天前
Git 完全指南 —— 第1章:Git 概览与版本控制演进
git
noravinsc8 天前
关于Git Flow
git
蜜獾云8 天前
在Git中配置用户名和密码
git