git新建分支和合并fork分支

git新建分支和合并fork分支

1.新建和删除分支

javascript 复制代码
git checkout --orphan emptybranch
git rm -rf .
echo '# new branch' >> README.md
git add README.md
git commit -m 'new branch'
git push origin emptybranch

2.回滚代码

javascript 复制代码
git reset --hard 目标版本号"
git push -f

3.合并分支

javascript 复制代码
git remote add upstream <原仓库git地址>
git fetch upstream
git merge origin2/master --allow-unrelated-histories

4.删除分支

javascript 复制代码
git checkout <another_branch>
git branch -d <branch_name>
git branch -D <branch_name>
git push <remote_name> --delete <branch_name>

5.仓库迁移

javascript 复制代码
git clone --bare ssh://url
cd xxx-ui.git/
git push --mirror ssh://url
相关推荐
xxwl5856 小时前
Git 完整学习笔记:从入门到团队协作
笔记·git·学习
John_ToDebug9 小时前
Git 工作区、暂存区、仓库、远端同步完全指南:从 restore、reset 到 fetch、pull 的正确使用姿势
git·源代码管理
炸膛坦客21 小时前
Git 和 GitHub:(九)修改本地仓库内容并推送到远程仓库(关联/克隆)
git·github
To_OC1 天前
一次 git reset 翻车,让我彻底分清了 hard 和 soft,也想通了 Vibe Coding 的本质
git·程序员·vibecoding
Ai拆代码的曹操1 天前
Git 集成:AI 代理中的版本控制工作流设计
大数据·git·elasticsearch
lazy H1 天前
Git clone 怎么用?克隆项目及常见问题完整教程
大数据·git·后端·学习·搜索引擎·github
m0_743697591 天前
关于ftp与SELinux的冲突问题
git·github
前进的程序员1 天前
VS Code Git 工作树:多分支并行开发体验
git·vs code·git工作树
半夜修仙1 天前
二.Git分支管理
git
六bring个六1 天前
git使用笔记
笔记·git