美文网首页Git
本地库关联github遇到的问题

本地库关联github遇到的问题

作者: 郭之源 | 来源:发表于2016-04-14 00:34 被阅读657次

今天想将一个本地的项目上传到github上,笔者首先在本地和github分别建立一个git库名叫ResDemo!但是在使用<code>$ git remote add origin git@github.com:watermin(github帐号名)/gitdemo(项目名).git</code>,将本地库与github上的库进行关联时,关联错了!导致执行<code>git push origin master</code>时出现错误!
<pre>$git push origin master
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.</pre>
出现错误后,我想试着从新关联github远程库,但是当执行<code>git remote add origin git@github.com:watermin/DesDemo.git</code>时提示以下错误:
<pre>$ git remote add origin git@github.com:watermin/DesDemo.git
fatal: remote origin already exists.</pre>
意思是说,已经关联了远程库,再次关联就失败了!
后来在网上看到说,先使用<code>git remote rm origin</code>,在进行关联远程库,果然这样就可以了!下面简单写一下步骤:

1.将关联错误的远程库移除
<code>$ git remote rm origin</code>
2.重新关联远程库
<code>$ git remote add origin git@github.com:watermin/DesDemo.git</code>
3.将本地库代码push到远程库
<pre>
$ git push origin master
Counting objects: 76, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (59/59), done.
Writing objects: 100% (76/76), 8.32 MiB | 372.00 KiB/s, done.
Total 76 (delta 1), reused 0 (delta 0)
To git@github.com:watermin/DesDemo.git

  • [new branch] master -> master
    devteam@LENOVO-PC ~/Desktop/git/DesDemo (master)
    $</pre>
    这样就成功将本地库代码,上传到远程库了!

一些git常用的命令

  1. git创建本地分支并推动到远程:
    git branch dev
    git checkout dev
    以上两条命令等同于
    git checkout -b dev
    // 第一次push时需要创建一个远程的upsteam
    git push --set-upstream origin dev

  2. git将本地分支与远程分支进行关联:
    git branch --set-upstream-to=origin/master master

  3. 关联后执行git pull 如果报错:
    fatal: refusing to merge unrelated histories可执行git pull origin master --allow-unrelated-histories将远程分支的历史数据同步下来

相关文章

  • 本地库关联github遇到的问题

    今天想将一个本地的项目上传到github上,笔者首先在本地和github分别建立一个git库名叫ResDemo!但...

  • 提交到github

    github 官网:https://github.com/ windows 设置: 通过key关联本地库和远程库:...

  • git 操作 - 1

    1、创建本地库 在github网站进行创建。 2、在本地pc上创建库和github的远程库进行关联,有两种选择: ...

  • Github(远程库)

    1.创建github远程库https://github.com/ 2.配置本地关联远程连接 git remote ...

  • [Git]-007 本地库如何关联远程库

    问题:如果我们本地已有一个版本库,我们想要关联到Github上的远程库,并让两个仓库远程同步,我们需要如何做? 操...

  • git 学习笔记3

    关联远程库及push origin表示远程库(GitHub) -u的作用:是把本地的master分支内容推送到远程...

  • 关联本地git库到github远程库

    场景:我们在本地已经创建了git版本库,需要提交到远程库 第一步:在GitHub上创建远程库 第二步:创建完成后,...

  • git 本地库同时与多个远程库互相同步(小计)

    查看本地关联的所有库 git remote -v 删除本地关联的库 git remote rm origin(远程...

  • git提交到GitHub基本操作

    windows 可视化命令行(推荐) 设置: 配置用户名和密码: 通过key关联本地库和远程库: github 请...

  • 创建自己的cocoapods库

    一、创建自己的git账号,并将自己的电脑与指定github账户关联。 二、创建本地仓库 1.创建本地库打开终端,进...

网友评论

    本文标题:本地库关联github遇到的问题

    本文链接:https://www.haomeiwen.com/subject/elrglttx.html