0

我想在我现有的项目中使用git ,所以我在github 上为它创建了一个空间,并在我的主机上的项目文件夹中我做了通常的操作:

$ git config --global user.name myname
$ git config --global user.email "myemail@email.com"
$ cd myProjectFolder/
$ git init
$ git add .
$ git commit -m "first commit"
$ git remote add origin https://github.com/myusername/myprojectname.git

然后我希望我的项目的所有文件也在在线存储库中:

$ git push origin master

但我得到了以下可怕的错误:

To https://github.com/myusername/myprojectname.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/myusername/myprojectname.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

现在,我不需要pull从在线存储库中获取任何信息,因为那里仍然没有任何内容。我为什么要拉?

无论如何,我应该在这里做什么才能让我的所有文件在线并开始使用 git?

4

1 回答 1

1

之后git remote add,远程 repo 的 URL 在你的中是已知的,但还不是它的内容。

git fetch origin(或)之后git pull,您可以知道远程仓库的内容。git push

于 2013-01-09T11:45:28.517 回答