1 将本地项目推送至远端
初始化 react 项目时,发现同时产生了 master 分支
npx create-react-app my-app # 初始化 react 项目
试着 push,报错 从命令行指定URL 或 使用配置远程存储库
$ 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>
采用 从命令行指定URL, 按照提示
- remote
先在 github 上新建一个项目,用其 https 作为 url
$ git remote add origin https://github.com/xxx/yyyy.git # 添加远端仓库 取名为origin
- push
$ git push origin # 当前分支推送到 origin 主机的对应分支
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
远程没有 master 分支,所以
$ git push --set-upstream origin master