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>

相关推荐
我家媳妇儿萌哒哒17 小时前
git:无法推送refs到远端。您可以试着运行“拉取”功能,整合您的更改。
git
驯龙高手_追风20 小时前
Gitlab本地服务器搭建及配置-详细教程
git·github
czhc114007566321 小时前
6.11:halcon,Sqlserver;项目sql连接;git
git·sql·sqlserver
炸炸鱼.1 天前
Git+Jenkins 基本使用:从入门到实战(知识点大全)
运维·git·jenkins
戴国进1 天前
git stash 用法详解
git
木雷双雄71 天前
Git 版本回退操作指南
git
m0_579146651 天前
已被 Git 追踪的本地修改文件如何实现临时忽略
git
糖少主2 天前
WSL中使用Beyond Compare 3/4/5作为difftool
git·wsl·beyond compare·difftool
console.log('npc')2 天前
Git版本管控:git reset \+ git push \-f 原理、实操与避坑指南
git
恋喵大鲤鱼2 天前
git reflog
git·git reflog