[git] git怎样fork一个repo

描述

我定制了一下strongswan的工程。然后想把我自己的定制变成一个repo
push到远端git.tong.com与大家分享。
这个时候,应该怎么做?

如果你用过github的话。那么你可以理解,我现在要做的事情就是类似于github上的fork。

开始

1

从strongswan的git上checkout下来它的代码
建立一个新的本地分支,并完成定制修改,放在了新的branch里,我给它起了个名字
叫 tong_plugin,tong_plugin是从version5.7.2分出来的。

╰─>$ git branch -v
* tong_plugin f5059bb85 kernel_tong works verison.
  master        6639288b1 [behind 1] Use Botan 2.9.0 for tests

2

在你的远端服务器上,建好仓库。无论是通过命令行或者网页或者客户端。
总之,它最后会给你一个地址:

[email protected]:caotong1/strongswan.git

你应该明白,git是真正的分布式的,没有谁是谁的仓库,每一个节点都有完整的信息,任何人随时都可以成为任何人的仓库,只要网络可达,只要服务开放访问
这个服务可以是http承载,也可以是ssh承载

3

在本地,用以下命令增加一个remote:
``
┬─[tong@T7:~/Src/thirdparty/strongswan.git]─[06:24:39 PM]
╰─>$ git remote add tong_repo [email protected]:caotong1/strongswan.git

可以看到,现在你有两个remote了,不要以为所有的remote都只能叫origin。。。。

┬─[tong@T7:~/Src/thirdparty/strongswan.git]─[06:25:02 PM]
╰─>$ git remote -v
tong_repo [email protected]:caotong1/strongswan.git (fetch)
tong_repo [email protected]:caotong1/strongswan.git (push)
origin git://git.strongswan.org/strongswan.git (fetch)
origin git://git.strongswan.org/strongswan.git (push)


## 4
把修改的分支push上去。原来的属于官方的还留在官方的远端repo里

git push -u tong_repo tong_plugin
```


猜你喜欢

转载自www.cnblogs.com/hugetong/p/10305678.html
Git
今日推荐