将一个 Git 仓库的分支代码和提交记录复制到另一个仓库下的分支

# 在本地克隆源仓库
git clone <源仓库的URL> source-repo

# 进入克隆的源仓库目录
cd source-repo

# 检查源仓库中的所有分支
git branch -a

# 切换到源仓库的 source-branch 分支
git checkout source-branch

# 将源仓库的 source-branch 分支重命名为 target-branch 分支
git checkout -b target-branch

# 推送新的 target-branch 分支到目标仓库
git remote add target-repo <目标仓库的URL>
git push target-repo target-branch

posted @ 2023-09-07 10:36  善逸a  阅读(1017)  评论(0)    收藏  举报