[英]Copying git branch into new repository as master
I have a git repository called RepA. 我有一个名为RepA的git存储库。 'RepA' has 2 Branches 'Master' and 'RandomStuff'.
“ RepA”具有2个分支“ Master”和“ RandomStuff”。 I have another repository called 'RepB' that has has a git init done on it and that's it.
我有另一个名为“ RepB”的存储库,上面已经完成了git init。 How would I go about copying the 'RandomStuff' Branch into the 'RepB' Repository and have it acting as the Master of that Branch.
我将如何将“ RandomStuff”分支复制到“ RepB”存储库,并使其充当该分支的主服务器。
Any help would be great. 任何帮助都会很棒。
Cheers 干杯
Same way you put any files in a master branch: just have RepB set to the master
branch, make sure RepA is set to the RandomStuff
branch. 将文件放在master分支中的方式相同:只需将RepB设置为
master
分支,确保RepA设置为RandomStuff
分支。 Then use a file manager (or a tactical cp
) to copy all the files (but not the .git
directory!) from the RepA dir to the RepB dir. 然后使用文件管理器(或战术
cp
)将所有文件(而不是 .git
目录!)从RepA目录复制到RepB目录。 Then you add all those files, create a commit, and push them up: 然后添加所有这些文件,创建一个提交,然后将它们上推:
$RepA> git checkout RandomStuff
and: 和:
$RepB> git checkout master
and after copying the content from RepA to RepB: 并将内容从RepA复制到RepB之后:
$RepB> git add -A
$RepB> git commit -m "copy of RepA's RandomStuff branch"
$RepB> git push origin master
Assuming you are in RepA/master, 假设您在RepA / master中,
git pull <repB> RandomStuff
(where <repB>
is either a path or URL to your other repository) should merge RandomStuff
into current (blank) master
, preserving RepA history. (其中
<repB>
是其他存储库的路径或URL)应将RandomStuff
合并到当前(空白)的master
,从而保留RepA历史记录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.