5

我有一个我一直在从事的项目,称为“系统”,我将其设置为存储库。我一直在推动项目(system.git)。

现在我想将它发布到像 github 这样的网站。在不丢失我的历史记录的情况下,将我当前的项目推送到新的 github 项目中的最佳方法是什么?

谢谢!

4

3 回答 3

9

在 Github 上创建 repo。

然后您将原点设置为该项目

git remote add origin [git hub url]

然后做一个:

git push origin [branch name]

你会将本地存储库推送到 Github(包含所有历史记录等)

于 2009-08-25T18:51:37.603 回答
2

这确实是对黑客对 ghills 答案的评论的回复,但它有点长,所以不喜欢我在评论中放一堆代码。

...或者您可以使用“起源”以外的名称。例如,我有一个存储库,其中我的“master”分支推送到一个 github 存储库,而“hacking”分支推送到另一个。

在 .git/config 中,我有这个:

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git@github.com:xiongchiamiov/fourU.git
[branch "hacking"]
    remote = origin
    merge = refs/heads/hacking
[remote "main"]
    url = git@github.com:xyztextbooks/fourU.git
    fetch = +refs/heads/*:refs/remotes/main/*
[branch "master"]
    remote = main
    merge = refs/heads/master
于 2009-08-25T19:57:56.800 回答
0

对于管理远程分支的跟踪也很有用。

于 2009-08-25T20:09:47.743 回答