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>

相关推荐
可乐_不渴14 小时前
【Linux】 项目自动化构建工具makefile&& 版本管理Git&&第一个程序
linux·git·自动化·1024程序员节
lzx_00217 小时前
Linux 开发工具(六) 版本管理器git的简单使用
git·1024程序员节
jiangliushi618 小时前
GPT-6.1 Sol 免费用:git status 里中文文件名变成一串数字乱?条命令改好
git·codex·1024程序员节
import_random2 天前
[git]只有git,没有github, 如何工作
git·github
import_random2 天前
[git]先创建远程仓库or先创建本地项目
git·github
Linux实战笔记2 天前
rebase 变基引发提交哈希重写与指针机制分析
git·rebase·提交哈希·分支模型·代码合并
小稀土1232 天前
私有化研发协同系统并行期:旧 Jira 与新 Git 并存 6 条数据规则
git
Madison-No72 天前
Git版本控制工具(二)
git
Brookty2 天前
Git 与 GitHub|第一阶段:仓库、版本历史与 Git 对象模型(上篇)
git·github
Kimnol2 天前
我的第一次 Git 贡献:从 fork 到合并 PR #3130
git