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
相关推荐
小黑要努力11 分钟前
智能音箱遇到的问题(一)
linux·运维·git
RePeaT19 分钟前
【git】指令场景实战:单分支与多分支协作流程
git
前端Hardy2 小时前
杀疯了!Git 2.54 正式发布,3个封神新特性,效率直接翻倍!
git
Eloudy3 小时前
迁移带有 git lfs 功能的 github 仓库
git·github
xlq223224 小时前
1.git
git
运维全栈笔记6 小时前
零基础掌握Jenkins CI/CD:Java项目自动构建与部署全流程指南
git·servlet·ci/cd·gitee·自动化·jenkins·devops
菜萝卜子7 小时前
【Git】GitLab 18.9 全局服务器钩子(Server Hooks)官方规范与落地实践
服务器·git·gitlab
用户11481867894848 小时前
Git Stash 丢失后的完整找回指南
前端·git
Ting.~8 小时前
GIT详解
java·笔记·git
克拉拉KLARA8 小时前
vscode禁用在git提交中插入ai coauthor copilot
git·vscode·copilot