git:从public github克隆到私有github

时间:2016-03-21 17:06:32

标签: git github version-control

(欺骗声明)pull/push from multiple remote locations无关;我不需要多个位置,只需要在内部和公共github之间进行交互。 (尾注)

我正在寻找工作流程:

  • 将github.com的回购克隆到内部github服务器(不是github.com上的私人回购)
  • 使用内部github服务器进行更改和测试
  • 可能会将更改从外部github提取到我们的内部github
  • 查看更改,将拉取请求发送到原始github repo

git incantations将执行这三种互动?

  • 从公共克隆到内部github
  • 将更改从公共内容拉到内部github
  • 将更改从内部推送到公共github

1 个答案:

答案 0 :(得分:3)

两台Git服务器之间的大多数管理都将在它们之间管理单独的remote

如果您明确了解pushpull,则可以定义一个非常合理的工作流程。

  

从公共克隆到内部github

# this will be a one-time setup

# first clone the public repo
cd /dir/where/you/want/your/repo
git clone <public github url> myRepo
cd myRepo

# create a remote to your internal Git server
git remote add internal <internal repo url>

# push to your internal repo
# (assuming you are working on the master branch)
git push internal master

# now you have effectively "cloned" the public repo
# to your internal server
  

将更改从公共内容拉到内部github

# assuming you are on master branch
# and _not_ taking tracking branches
# into account (since IMO they complicate matters)
git checkout master

# pull from github
git pull origin master

# push to internal
git push internal master
  

将更改从内部推送到公共github

git checkout master
git pull internal master
git push origin master