![](/img/trans.png)
[英]Moving part of Git repository to another repository preserving history
[英]Moving GIT repository (and commit history) to another repository currently empty
我在GIT存儲庫repA
有一個代碼,我需要將其移到當前為空但現在在repB
具有repA
的提交和標記歷史記錄的另一個存儲庫repB
中。
關於此過程的工作流程/命令有什么建議嗎?
提前致謝!
您只需要添加新的遙控器,然后將代碼推送到新的倉庫即可
git remote add origin2 <url>
git push origin2 <branch name>
這是一個即時消息,即時消息用於簽出所有分支並將其推送到新的遠程站點
# first add the new rmeote
git remote add origin2 <new-url>
#!/bin/bash
# loop over all the original branches
# 1. check them out as local branches
# 2. set the origin as the track branch
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do
git branch --track ${branch#remotes/origin2/} $branch
done
# now push all branches and tags
git push origin2 --all
git push origin2 --tags
git branch -a
獲取所有本地分支機構的列表
| grep remotes
| grep remotes
分支名稱為:'remotes / origin /',因此將從分支名稱中刪除遠程
| grep -v HEAD | grep -v master
刪除主節點(當前分支)和HEAD ,這是最新提交的別名
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.