首页 > 解决方案 > 如何从 git 存储库中取消链接分支?

问题描述

我想直接将内容推送到新的存储库。

目前,内容存在于现有存储库的其中一个分支中。
我已经试过了git remote remove origin
但是当我输入时git branch,它显示的是以前的现有分支。需要帮忙。

标签: git

解决方案


我想直接将内容推送到新的存储库

按着这些次序:

  1. 创建新存储库
  2. 将新存储库添加为新远程
  3. 将您想要的分支推送到新的远程
  4. (可选)从第一个远程删除分支

# 1. Create new repository
#    Under your git server create new repository

# 2. Add the new repository as new remote
git remote add remote2 <url>

# 3. Push your desired branch to the new remote
git push origin2 <branch name>

# 4. OPTIONAL
#    delete the branch from the first remote
git push origin :<branch name>

推荐阅读