2018-07-11 Github创建本地分支、在远程仓库

原本先cd到目录下,然后git init,接着直接用git branch + 分支名,报错:

fatal: Not a valid object name: 'master'.

其实这是因为现在还没有添加项目文件到本地缓存。需要先git add . 添加想要的文件到本地仓库缓存,然后git commit -m "xxxx"提交到本地仓库,此时才能创建分支。

在本地创建好了分支以后,可以把本地分支推到远程分支上:

一开始直接就用了git push origin 本地分支名:远程分支名。结果报错:

fatal: 'origin' does not appear to be a git repository

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.fatal: 'origin' does not appear to be a git repository

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

这是因为现在终端还没有连接远程服务器。

我们可以增加一个名为orgin的远程服务器。使用这个命令:git remote add origin + url 

之后就可以 git push origin 本地分支名:远程分支名(自己命名)

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1. 安装 Github 查看是否安装git: $ git config --global user.name "...
    Albert_Sun阅读 13,751评论 9 163
  • Git 基础 基本原理 客户端并不是只提取最新版本的文件快照,而是把代码仓库完整的镜像下来。这样一来,任何一处协同...
    __silhouette阅读 16,015评论 5 147
  • 当有些与他人有关的想法过于隐秘而不便明白的说出来,怎样晦涩又划重点的说出来就成为非常困难的事。 我是个很古怪的人,...
    青年A阅读 271评论 0 0
  • 雨云
    it803阅读 117评论 0 0
  • 目前个人总结三种方法 一.使用storyboard自定义UITableViewCell 在Storyboard的相...
    Flyman阅读 2,288评论 0 0