如何为现有项目创建git存储库

时间:2013-11-29 11:24:37

标签: git

我的本​​地计算机上有一些项目。我想将这些项目添加到我的github存储库中。为此,首先我创建了一个新的存储库然后在我的本地机器上我改为该目录并使用以下命令

git inint
git add *
git commit -m "message"
git remote add origin https://github.com/username/project.git
git push origin

但它说了

No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
Everything up-to-date

2 个答案:

答案 0 :(得分:3)

Perhaps you should specify a branch such as 'master'

很重要

使用其建议

git push origin master

答案 1 :(得分:0)

如果您没有指定要推送的引用,git将查询配置以了解该怎么做。默认行为(在git< 2.0中)匹配(来自git man-page):

matching - push all branches having the same name in both ends. This is for those who prepare all the branches into a publishable shape and then push them out with a
           single command. It is not appropriate for pushing into a repository shared by multiple users, since locally stalled branches will attempt a non-fast forward push if
           other users updated the branch.

如果您使用默认配置,似乎您没有名为master的分支(默认分支名称)。

在推送第一次提交时,应该使用完整语法,指定远程,本地引用和远程引用。我总是建议一直使用它,因为它会避免你推动你并不打算做的事情:

git push <remote> <local_ref>:<remote_ref>
git push origin master:master

通过这种方式,您可以创建新的远程分支,或者推送名称不同的分支。例如:

git push origin master:master_backup
git push origin dev:master