zoukankan      html  css  js  c++  java
  • 使用idea上传项目到gitHub

    上传项目到gitHub

    创建好后开始提交本地项目代码如图

    选中VCS选中图中的按钮如图所示

    然后再选中Src点中add按钮如图所示

    然后点中commit Directory后
    打开终端进行项目根目录下键入以下 命令:
    git remote add origin git@github.com:codegeekgao/Test.git(这里我写的自己的github地址,这里可以改成你自己的github项目)
    git push -u origin master //将本地仓库的东西提交到地址是origin的地址,master分支下 
    
    

    可能出现的报错异常

    出现错误 error:src refspec master does not match any
    引起该错误的原因是目录中没有文件,空目录是不能提交上去的.
    解决办法:

    在项目根目录下,创建README.md 文件即可
    
    $ touch README.md
    $ git add README,md
    $ git commit –m’first commit’
    $ git push origin master
    

    进一步可能再次出现Permission denied (publickey). fatal: Could not read from remote repository.
    这是因为本地没有ssh的密钥,生成密钥,在GitHub上添加这个ssh密钥即可,操作步骤如下:

    1.首先,如果你没有ssh key的话,在ternimal下输入命令:ssh-keygen -t rsa -C "youremail@example.com", youremail@example.com改为自己的邮箱即可,途中会让你输入密码啥的,不需要管,一路回车即可,会生成你的ssh key。(如果重新生成的话会覆盖之前的ssh key。)
    2. 若是window操作系统,会在C盘的用户目录下创建一个ssh目录,同理ios系统也是在用户目录下有ssh目录。
    

    用文本编辑器打开id_rsa.pub,复制里面的内容添加到github,如下图所示:
    

    添加之后验证SSH的密钥

    提示:Hi xxx! You've successfully authenticated, but GitHub does not provide shell  access.即为成功
    

    提示出错信息:fatal: remote origin already exists. 解决办法如下:


    然后再次输入git remote add origin git@github.com:codegeekgao/Test.git
    git push -u origin master
    然后会报以下错误:

    ! [rejected] master -> master (fetch first)
    error: failed to push some refs to 'git@github.com:qzmly100/repository-.git'
    hint: Updates were rejected because the remote contains work that you do
    hint: not have locally. This is usually caused by another repository pushing
    hint: to the same ref. You may want to first integrate the remote changes
    hint: (e.g., 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    

    这是因为:
    远程分支上存在本地分支中不存在的提交,往往是多人协作开发过程中遇到的问题,可以先fetch再merge,也就是pull,把远程分支上的提交合并到本地分支之后再push。
    如果你确定远程分支上那些提交都不需要了,那么直接git push origin master -f,强行让本地分支覆盖远程分支.


    作者:撩琼不止
    出处:https://www.cnblogs.com/codegeekgao/
    github:https://github.com/codegeekgao
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

     
  • 相关阅读:
    Kotlin开发 扩展函数在Android开发中的一些实用例子
    Kotlin开发 使用lambda实现接口回调
    Android开发 Camera2的CaptureRequest属性整理--完善中
    Android开发 Bitmap图像处理详解
    Android开发 Camera预览画面镜像问题
    Android开发 ViewPage2
    windows 服务器更新程序下载-修复漏洞
    JAVA实现数据等分,一个List分成多个List
    List<CourseRecord>转HashMap<Long, List<CourseRecord>>
    模拟服务器1.0——WebServer 、ClientHandler 接收请求、做出响应
  • 原文地址:https://www.cnblogs.com/codegeekgao/p/9572013.html
Copyright © 2011-2022 走看看