简体   繁体   English

将回购推送到远程存储库(GitHub)

[英]Pushing repo to remote repository (GitHub)

I'm new to Git/GitHub. 我是Git / GitHub的新手。 Trying to push my files to a new repo I have set up and it's not working. 尝试将文件推送到新的存储库中,但该文件无法正常工作。 Here's my process: 这是我的过程:

  1. Set up repo on GitHub. 在GitHub上设置仓库。
  2. Initialise remote on repo. 在仓库上初始化远程。 git remote add origiN <URL>
  3. Check it's ok. 检查没问题。 git remote -v

This seems to all go to plan, as Terminal returns 这一切似乎都按计划进行,随着航站楼的返回

origiN  <URL> (fetch)
origiN  <URL> (push)

...as expected. ...符合预期

Then, when I run git push , I get: 然后,当我运行git push ,我得到:

fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using

    git remote add <name> <url>

and then push using the remote name

    git push <name>

...but I thought I had already configured the remote repository? ...但是我以为我已经配置了远程存储库?

What am I missing? 我想念什么?

git push -u origin master

那你就可以git push

psydroyd answered whilst I was typing, but here is slightly more detail: 我输入时,psydroyd回答了,但这里有一些详细信息:

A repository can have multiple remotes. 一个存储库可以有多个远程服务器。 You can push to a remote explicitly by running: 您可以通过运行以下命令显式推送到远程服务器:

git push <remote> <branch>

But if you want git push to work without any additional parameters, you can use the --set-upstream option, aka -u , as in: 但是,如果您想让git push在不使用任何其他参数的情况下工作,则可以使用--set-upstream选项aka -u ,如下所示:

git push -u origin master

This sets up your local branch to track the remote master branch. 这将设置您的本地分支以跟踪远程master分支。 After this point, you can run: 之后,您可以运行:

git push

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM