简体   繁体   English

如何分叉和Git仓库到我的仓库

[英]How to fork and a Git repo to my repo

I have started using Git today and loving it. 我今天开始使用Git并喜欢它。

I have this doubt - could any one please help me out 我对此表示怀疑-有人可以帮我吗

A repo for eg https://github.com/octocat/Spoon-Knife can be forked by pressing fork on the page. 可以通过按页面上的fork来分叉例如https://github.com/octocat/Spoon-Knife的仓库。 This then appears in my github like this - https://github.com/usrname/Spoon-Knife.git 然后,它像这样出现在我的github中-https: //github.com/usrname/Spoon-Knife.git

I have a test git like this https://github.com/usrname/test.git 我有一个像这样的测试git https://github.com/usrname/test.git

And I want the Spoon-Knife to appear within 'test' repo like this https://github.com/usrname/test/Spoon-Knife 我希望Spoon-Knife像这样https://github.com/usrname/test/Spoon-Knife出现在“测试”仓库中

How to do this - please let me know. 怎么做-请让我知道。

You can, but then your https://github.com/usrname/test.git won't be a fork. 您可以,但是您的https://github.com/usrname/test.git不会成为叉子。
Just a regular cloned repo, without any special relationship with the original repo https://github.com/octocat/Spoon-Knife . 只是常规的克隆存储库,与原始存储库https://github.com/octocat/Spoon-Knife没有任何特殊关系。

  • git clone your fork git克隆你的叉子
  • make a local branch for any remote branch you have fetch with that clone: see the details in " Track all remote git branches as local branches " 为您使用该克隆获取的任何远程分支创建一个本地分支:请参阅“将所有远程git分支作为本地分支跟踪 ”中的详细信息
  • add test.git as a remote to your local clone, named ' test ' test.git添加为本地克隆的远程文件,名为“ test
  • push everything back to test.git 将所有内容推回test.git

That would be: 那将是:

git clone https://github.com/usrname/Spoon-Knife.git
cd Spoon-Knife
git fetch --tags
remote=origin ; for brname in `git branch -r | grep $remote | grep -v master | grep -v HEAD | awk '{gsub(/[^\/]+\//,"",$1); print $1}'`; do git branch --set-upstream-to $brname  $remote/$brname ; done
git remote add test https://github.com/usrname/test.git
git config push.default matching
git push --all
git push --tags
git config push.default simple

For the push policies (the config push.default part), see " What is the result of git push origin ? ". 有关推送策略( config push.default部分),请参阅“ git push origin的结果是什么? ”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM