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>

相关推荐
不老刘16 小时前
Antigravity 的 New Worktree 模式:给 AI 代理一个安全的“平行工位”
人工智能·git·ai编程·antigravity
光谱SpectrAI17 小时前
Windows 也中招:Git Bash 和 Node 仍信任泄露的 eMudhra 证书
git
YIN_尹17 小时前
【git原理与使用】git初识与安装
大数据·git·elasticsearch
Leo_Mr1 天前
Vue3 项目配置 Git 提交规范(企业通用方案:husky + commitlint + cz-git + lint-staged)
git
jyOverQ1 天前
Git rebase 和 merge 有什么区别?什么时候该用哪个?
git
晗夜未央1 天前
跨仓库 Skill 换台电脑就失效?用 Git remote 校验项目
人工智能·git·python
Lsetea1 天前
Git访问HTTPS证书不受信任:用URL级sslCAInfo限定私有CA范围
git·https·开发工具·ssl证书·ca证书
এ慕ོ冬℘゜2 天前
Git 基础入门|和 SVN 对比 + 四大区域 + 常用命令详解
git·svn
DevLoom_2 天前
macOS 命令行 curl/git 报 SSL 证书错误?eMudhra 事件完整修复指南
git·macos·ssl
keyipatience2 天前
Git学习(4)Git分布式优势与实战配置全解析
git·学习