git实用命令

删除分支

在命令行中输入以下命令可以删除一个本地分支:

npm 复制代码
git branch-d branch name

如果要删除一个远程分支,则需要使用以下命令:

xml 复制代码
git push origin --delete branch name

同步分支代码 cherry-pick

不同分支需要合并代码,但两个分支差异较大,不能直接合并分支,需要自己同步代码时,可以考虑使用这个方法。

合并单个 commit, 先切换到目标分支,执行命令:

xml 复制代码
git cherry-pick commit hash

1、没有冲突

xml 复制代码
git push

2、有冲突

需要先到 vscode 编辑器里解决代码冲突,再执行以下命令:

xml 复制代码
git add .
git cherry-pick --continue
git push
相关推荐
每天进步一点点️1 小时前
GIT - 常用命令合辑
git
csdn_aspnet1 小时前
Git Submodule深度避坑指南,破解子模块同步混乱、版本漂移、CI失败等高频协作痛点
git·ci/cd·submodule·checklist·detached·subtree
一个程序猿老马2 小时前
011、更优雅的合并:git rebase变基操作详解
git
zhensherlock5 小时前
Protocol Launcher 系列:Working Copy 文件操作与高级命令详解
javascript·git·typescript·node.js·自动化·github·js
摆烂z19 小时前
AI同时完成多个功能(Git WorkTree)
git
___波子 Pro Max.1 天前
Git Worktree 可视化理解指南
git
happymaker06261 天前
git使用快速入门
git
不做超级小白1 天前
从零到可用:在手机上用 Termux + Git + Obsidian 打造稳定同步环境(踩坑全记录)
git·智能手机
凡客丶1 天前
Git安装与使用保姆教程【超详细】
git
android_cai_niao1 天前
给Git项目添加多个远程仓库
git·gitee·github