我有一个微服务应用程序,所以第一个repo的前端和两个不同的repos上的两个不同的后端API。我想将所有这些添加到别人的空回购中,我不知道该怎么做。
我尝试做一个git远程添加其他人回购,我得到了这个:
danales-MacBook-Pro:freelance-camp-fe danale$ git remote add https://github.com/Meridian-Business-Centers/Interview-Sample-App.git
usage: git remote add [<options>] <name> <url>
-f, --fetch fetch the remote branches
--tags import all tags and associated objects when fetching
or do not fetch any tag at all (--no-tags)
-t, --track <branch> branch(es) to track
-m, --master <branch>
master branch
--mirror[=<push|fetch>]
set up remote as a mirror to push to or fetch from
当我做一个git remote添加microservice master时,我收到了这个错误:
danales-MacBook-Pro:freelance-camp-fe danale$ git push microservice master
remote: Permission to Meridian-Business-Centers/Interview-Sample-App.git denied to ldco2016.
fatal: unable to access 'https://github.com/Meridian-Business-Centers/Interview-Sample-App.git/': The requested URL returned error: 403
我尝试将其推送到我自己的分叉版本并收到此错误:
danales-MacBook-Pro:freelance-camp-fe danale$ git remote add microservice https://github.com/ldco2016/Interview-Sample-App.git
fatal: remote microservice already exists.
danales-MacBook-Pro:freelance-camp-fe danale$ git push microservice master
To https://github.com/ldco2016/Interview-Sample-App.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/ldco2016/Interview-Sample-App.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
danales-MacBook-Pro:freelance-camp-fe danale$ git push -u microservice master
To https://github.com/ldco2016/Interview-Sample-App.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/ldco2016/Interview-Sample-App.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
答案 0 :(得分:1)
进入每个单独的仓库并添加一个带personal
的遥控器(例如,url of other persons empty github repo
)。现在推送代码git push personal master
。
说,你有repo1,repo2和repo3。个人仓库perRepo
(想在这里添加repo1,repo2和repo3代码)。
# Go into repo1
$ git checkout master
$ git remote add personal <perRepo-url>
$ git push personal master
# Go into repo2
$ git checkout master
$ git remote add personal <perRepo-url>
$ git push personal master
# Go into repo3
$ git checkout master
$ git remote add personal <perRepo-url>
$ git push personal master
添加子模块:常规命令:git submodule add <git@XXX:YYY> <externals>
。
git submodule add
:告诉Git我们正在添加一个子模块git@XXX:YYY
:要作为子模块添加的外部存储库URL externals
:这是将子模块存储库添加到主存储库的路径。 将repo1
,repo2
和repo3
添加为perRepo
的子模块。
# Go into perRepo
$ git submodule add <repo1-url> <path>
$ git submodule add <repo2-url> <path>
$ git submodule add <repo3-url> <path>
$ git submodule update --init --recursive
N.B。当repo1
/ repo2
/ repo3
更新时,您需要运行git submodule update
命令以将更新的更改更新为perRepo
repo。