zoukankan      html  css  js  c++  java
  • Xcode连接git@osc

    一般依照这篇文章去做。应该能够成功 Xcode连接git@osc :http://my.oschina.net/zxs/blog/142544

    但近期特别恼火。在osc里新建了个项目。老是连接错误,经过几小时的搜索,终于还是搭建成功,特此记录下!
    接下来还是依照这篇博客步奏去走:

    第一步:成生SSH密钥

    打开终端命令工具,输入命令:ssh-keygen -t rsa -C "diaosi@gmail.com"

    注意ssh-keygen没有空格。屏幕输出:

    Generating public/private rsa key pair.

    Enter file in which to save the key (/Users/diaosi/.ssh/id_rsa):diaosi

    在上方输入生成的密钥文件名称,如diaosi,屏幕输出:

    Enter passphrase (empty for no passphrase): 输入password

    Enter same passphrase again: 确认password

    Your identification has been saved in diaosi.

    Your public key has been saved in diaosi.pub.

    The key fingerprint is:

    25:fd:01:00:89:98:49:bf:2e:ac:32:2e:d2:5d:bf:98 diaosi@gmail.com

    The key's randomart image is:

    +--[ RSA 2048]----+

    | ..+ ..o...      |

    |  +.. .  . .     |

    |    .   . o .    |

    |     .   o . .   |

    |    .   S   .    |

    | . .  .          |

    | .o... .         |

    |=....  o.        |

    |*o    E ..       |

    +-----------------+

    屏幕提示生成密钥文件成功。保存在/Users/diaosi目录下。

    第二步:把diaosi.pub中的内容增加git@osc SSH密钥中

    以下标题随便起,把生成的公钥拷贝到公钥区

    第三步:加入SSH并连接

    输入命令:ssh-add ~/diaosi

    ~/diaosi 是刚刚生成的密钥文件路径,屏幕输出:

    Enter passphrase for /Users/diaosi/diaosi:输入password

    Identity added: /Users/diaosi /diaosi (/Users/diaosi /diaosi)

    输入命令ssh -T git@git.oschina.net。屏幕输出:

    The authenticity of host 'git.oschina.net (58.215.179.44)' can't be established.

    RSA key fingerprint is 14:b8:b8:0b:c2:b2:5e:ae:f2:21:f8:18:4d:3a:be:fc.

    Are you sure you want to continue connecting (yes/no)?

    yes(输入yes),屏幕输出:

    Warning: Permanently added 'git.oschina.net,58.215.179.44' (RSA) to the list of known hosts.

    Welcome to Git@OSC , 老左!


    第四步:设置个人信息

    输入命令:

    git config –global user.name “diaosi”

    git config –global user.email diaosi@gmail.com

    第五步:设置项目【我的问题就出如今这步】

    获取git@osc 上的项目路径。


    输入命令:cd 项目文件

    输入命令:git init 【须要初始化。error:fatal: Not a git repository (or any of the parent directories): .git

    输入命令:git remote add origin git@git.oschina.net:heqings/fitness.git // /这个相当于指定本地库与github上的哪个项目相连

    输入命令:rm -fr ~/.ssh/known_hosts【清空文件中的内容:rm -fr /文件夹名/*】

    输入命令:git add -A 【加入整个项目】

    输入命令:git commit -m "加入整个项目"

    // 不进行上面两步,会抛出error: src refspec master does not match any.

    //输入命令:git pull -u origin master //git@osc 上拉取项目

    输入命令:git push -u origin master //提交项目

    这里就可以完毕提交!





    git init 产生的文件夹解释
    error: src refspec master does not match any.
    引起该错误的原因是。文件夹中没有文件。空文件夹是不能提交上去的
    

    error: insufficient permission for adding an object to repository database ./objects
    服务端没有可写文件夹的权限

    错误提示:fatal: remote origin already exists.
    解决的方法:$ git remote rm origin
    错误提示:error: failed to push som refs to ........
    解决的方法:$ git pull origin master //先pull 下来 再push 上去

    git init //在当前项目project下履行这个号令相当于把当前项目git化,变身!

    
    

    git add .//把当前目次下代码參加git的跟踪中。意思就是交给git经管。提交到本地库

    
    

    git add <file> //把当前文件參加的git的跟踪中,交给git经管,提交到本地库

    
    

    git commit -m “…”//相当于写点提交信息

    
    

    git remote add origin git@github.com:ellocc/gittest.git //这个相当于指定本地库与github上的哪个项目相连

    
    

    git push -u origin master //将本地库提交到github上。

    
    

    git clone git@github.com:ellocc/gittest.git  //将github上的项目down下来。

    
    

    git fetch origin //取得长途更新,这里能够看做是筹办要取了

    
    

    git merge origin/master //把更新的内容归并到本地分支/master

    
    

    以下是删除文件后的提交

    
    

    git status //能够看到我们删除的哪些文件

    
    

    git add .   //删除之后的文件提交git经管。

    
    

    git rm a.c //删除文件

    
    

    git rm -r gittest //删除目次

     

    git reset --hard HEAD 回滚到add之前的状态
    git diff比較的是跟踪列表中的文件和文件系统中文件的区别


  • 相关阅读:
    守望先锋-生涯数据信息抓取的实现
    Norm 数据库操作竟然可以如此简单
    java中关于转义字符的一个bug
    在Java中==的一个坑
    人机ai五子棋 ——五子棋AI算法之Java实现
    MySQL数据库罕见的BUG——Can't get hostname for your address
    [疑难杂症]__关于cmd命令正确而显示不是内部指令的错误(ps:已解决)
    [疑难杂症]__点击win10屏幕最上方的边界会莫名其妙打开Internet Explorer浏览器,不胜其烦(2次ps:已解决!!!).
    [Java初探外篇]__关于正则表达式
    [java初探外篇]__关于StringBuilder类与String类的区别
  • 原文地址:https://www.cnblogs.com/cxchanpin/p/7089912.html
Copyright © 2011-2022 走看看