I have a git repository called RepA. 'RepA' has 2 Branches 'Master' and 'RandomStuff'. I have another repository called 'RepB' that has has a git init done on it and that's it. How would I go about copying the 'RandomStuff' Branch into the 'RepB' Repository and have it acting as the Master of that Branch.
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. 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. 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:
$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,
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.