我在GitHub上有一个私人仓库。我的计算机上有本地工作区。
我在Perforce中有一些depo流,使用“ git p4 clone”将其复制到计算机上的本地repo工作区中。原因是保留Perforce的历史记录。
现在,我想将从Perforce克隆的本地存储库推送到GitHub上的现有私有存储库(我一开始提到的存储库)。
任何人都可以指导我执行这些步骤吗?
到目前为止,我尝试了:
git p4 clone "my-perforce-stream-path"
然后我尝试了:
git remote add origin "my-private-github-repo-url"
git push -u origin master
我收到一个错误:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'my-private-github-repo-url'
您首先需要从perforce存储库中拉入私有github存储库。一旦这样做,并且github repo与perforce同步,就可以将master分支推送到github repo。请按照以下两种选择之一来完成此操作:
选择1
创建github存储库的本地副本:
git clone your-github-repo.git
添加遥控器:
git remote add p4 "perforce-repo-path"
将更改从p4
遥控器拉到本地:
git pull p4 branch-name
3.1。注意:如果两个仓库,github和perforce都不相关(意味着它们彼此包含不相关的历史记录),则可能会出现错误,因为git不允许您将一个分支与一个不相关的仓库合并。您可以使用该--allow-unrelated-histories
选项覆盖它,如下所示:
git pull p4 branch-name --allow-unrelated-histories
最后,您应该能够将本地更改推送到github:
git push -u origin master
选择2
在perforce仓库中添加github遥控器:
git add remote github url.git
接下来,确保将github远程分支的历史记录拉入本地perforce存储库中(在推送之前将其同步):
git pull github <branch-name> --allow-unrelated-histories
(--allow-unrelated-histories
如果两个存储库都包含无关的更改/历史记录,则可以帮助您防止收到错误消息)
然后,在perforce存储库中将您的分支推送到github远程:
git push -u github <branch-name>
注意:如果您对历史记录有任何疑问,可以在--allow-unrelated-histories
此处使用相同的标志。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句