Git:初始化了一个空的存储库,但是不能推或拉

时间:2018-09-05 11:52:21

标签: git

在这种情况下,我看到了很多问题,并尝试了那里提供的解决方案,但由于某种原因对我不起作用。

因此,我创建了一个空项目,并使用git initdocumentation)对其进行了初始化。

git remote -v给了我这个:

origin  https://path_to_/my_project.git  (fetch)
origin  https://path_to_/my_project.git (push)

运行git pull时出现此错误:

There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

当我运行git push origin master时,出现此错误:

error: failed to push some refs to 
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

当我运行git push -f origin master(如我看到的许多解决方案中所建议)时,出现此错误:

error: src refspec master does not match any.
error: failed to push some refs to 'https://path_to/my_project.git'

其他信息:git branch -r告诉我:

 origin/master

我应检查哪些信息以解决此问题?

1 个答案:

答案 0 :(得分:2)

将远程分支设置为本地分支的上游:

git branch -u origin/master

然后拉动

git pull
相关问题