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>

相关推荐
减瓦15 小时前
Windows 环境使用 Git Bash 最佳实践
windows·git
史呆芬15 小时前
CodeX多仓库提交Skill搭建
git·后端·openai
城东16 小时前
Git使用[原意要新建分支提交但是误提交到原来分支恢复办法]
git·原意要新建分支提交·但是误提交到原来分支
开发者联盟league16 小时前
git 压缩本地最近多个commit
git
赵庆明老师1 天前
Vben精讲:04-了解VSCode中的Git
ide·git·vscode
Irissgwe1 天前
第 5 篇:Git 分支基础:branch、checkout、merge 和冲突解决
git
liberalhumblehopeful1 天前
git代码管理-分支差距过大如何进行同步
git
一只楚楚猫2 天前
一篇文章入门Git工具
git
Irissgwe2 天前
第 6 篇:Git 分支进阶:分支策略、stash、bugfix 和 feature 开发
git