• 上传工程到github


    这里主要讲讲如何在mac底下使用github,我刚开始使用时,还是费了一点功夫的,因为网上的资料比较杂,有些不是太准确。故将自己的安装过程比较详细的分享下,方便有需要的人,攒点人品。

    首先你得完成如下两个工作:

    1. 下载安装git客户端 http://code.google.com/p/git-osx-installer/downloads/list?can=3
    2. 注册github账号 https://github.com/ -->Pricing and Signup -->Create a free account

    创建ssh:   

         接下来打开终端(不知道终端在哪儿的,就直接在spotlight里搜terminal): 

         cd ~/.ssh 检查是否已经存在

      如果存在,(一般情况下都不会存在)先将已有的ssh备份,或者将新建的ssh生成到另外的目录下

         如果不存在,通过默认的参数直接生成ssh:

     先  cd -/.ssh 会出现如下图:

    邮箱地址填写自己注册github 的邮箱地址.

     登陆github,选择Account Settings-->SSH  Keys 添加ssh

          Title:xxxxx@gmail.com(自己的邮箱)

           Key:打开你生成的id_rsa.pub文件,(前往文件夹;路径是/Users/你的home文件夹/.ssh/id_rsa.pub,比如:/Users/chendianming/.ssh/id_rsa.pub),之后将其中内容拷贝进去:

    打开终端,先测试一下你的帐号跟github连上没有:ssh -T git@github.com 如果出现如下提示,表示你连已经连上了.(因为有了第一步,所以不用自己做过多的连接github的操作了,另外,下一次要连接github的时候记得打开第一步的工具).

    如果出现The authenticity of host 'github.com (192.30.253.112)' can't be established.  Are you sure you want to continue connecting (yes/no)? 请输入yes 

    原因: 1.github上没有与本地仓库相关联(少数情况)

          2.ssh 不对 (基本上都是这样的情况)

    ssh 解决: 

    1.  cat ~/.ssh/id_rsa.pub 查看ssh是否是自己的(后面是你自己的邮箱说明是自己的),不是说明是ssh问题,是的话就是远程关联问题

    2. 如果是ssh问题则在git仓库同目录 删除.ssh文件夹 (隐藏文件夹)

    判断删除成功: cat ~/.ssh/id_rsa.pub

    出现cat: /c/Users/用户名/.ssh/id_rsa.pub: No such file or directory

    3.重新创建ssh  ssh-keygen -t rsa -C "your_email@example.com“

    如果出现 Hi domanc! You've successfully authenticated, but GitHub does not provide shell access. 说明成功.

     

    接下来就可以上传你的代码了,在github下建自己的Repository。Create a New Repository如下:

    Repository name:通常就写自己自己要建的工程名。

    Description:就是你对工程的描述了。

    选择Public。

    Add.gitignore 选择那种语言

    Add a license 选择一种协议,具体见下面这个,也可以自行度娘:

    https://www.zhihu.com/question/27114031

    上面操作成功后会到:

    接下来创建一个test工程,然后在终端输入一下命令:

    1.cd /Users/chendianming/Desktop/test

    2.git init

    3.git add -A

    4.git commit -m "init file"

    5.git remote add origin git@github.com:domanc/test.git

    6.git push -u origin master

    如果出现一下错误: 

    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 上去

    刚创建的github版本库,在push代码时出错:

    $ git push -u origin master
    To git@github.com:******/Demo.git
     ! [rejected] master -> master (non-fast-forward)
    error: failed to push some refs to 'git@github.com:******/Demo.git'
    hint: Updates were rejected because the tip of your current branch is behind
    hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
    hint: before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.

    网上搜索了下,是因为远程repository和我本地的repository冲突导致的,而我在创建版本库后,在github的版本库页面点击了创建README.md文件的按钮创建了说明文档,但是却没有pull到本地。这样就产生了版本冲突的问题。

    有如下几种解决方法:

    1.使用强制push的方法:

    $ git push -u origin master -f

    这样会使远程修改丢失,一般是不可取的,尤其是多人协作开发的时候。

    2.push前先将远程repository修改pull下来

    $ git pull origin master

    $ git push -u origin master

    3.若不想merge远程和本地修改,可以先创建新的分支:

    $ git branch [name]

    然后push

    $ git push -u origin [name]

     出现这个错误:

    ! [rejected]        master -> master (non-fast-forward)

    详情见这个 http://blog.csdn.net/chain2012/article/details/7476493

  • 相关阅读:
    WCF 第十三章 可编程站点 为站点创建操作
    WCF 第十三章 可编程站点 所有都与URI相关
    WCF 第十二章 对等网 使用自定义绑定实现消息定向
    WCF 第十三章 可编程站点 使用WebOperationContext
    Using App.Config for user defined runtime parameters
    WCF 第十三章 可编程站点
    WCF 第十三章 可编程站点 使用AJAX和JSON进行网页编程
    WCF 第十二章 总结
    WCF 第十三章 可编程站点 使用WebGet和WebInvoke
    WCF 第十三章 可编程站点 URI和UriTemplates
  • 原文地址:https://www.cnblogs.com/dianming/p/6601453.html
Copyright © 2020-2023  润新知