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>

相关推荐
wh_xia_jun7 小时前
Git 分支合并操作备忘录
git
满天星83035778 小时前
【Git】原理及使用(三)(分支管理)
linux·git
像风一样的男人@12 小时前
warning: could not find UI helper ‘git-credential-manager-ui‘
git·ui
代钦塔拉13 小时前
Git & GitHub 从入门到精通:全流程实战教程
git·github
晚风吹红霞14 小时前
Linux下的趣味编程 —— 进度条、Git版本控制与GDB调试实战
linux·运维·git
xlq2232215 小时前
7.git
git
Ws_15 小时前
Git + Gerrit 第六课:commit --amend、Patch Set 与 Change-Id
git
AIMath~1 天前
向github中上传文件过大超过50M怎么办
网络·git·github
AIMath~1 天前
如何将一个新的文件夹使用git 工具提交到github新仓库中
git·github
满天星83035772 天前
【Git】原理及使用(二) (版本回退)
linux·git