zoukankan      html  css  js  c++  java
  • 使用Github时遇到问题的解决方法

    git中报unable to auto-detect email address 错误的解决办法

    问题描述:

    执行
    
    git commit -m "first commit"
    
    报错
    
    fatal: unable to auto-detect email address

    昨天刚配置好的git,今天刚要commit一些修改,就遇到了这个问题

    ** Please tell me who you are.
    
    Run
    
      git config --global user.email "you@example.com"
    
      git config --global user.name "Your Name"
    
     
    
    to set your account's default identity.
    
    Omit --global to set the identity only in this repository.
    
     
    
    fatal: unable to auto-detect email address (got 'tim@newton.(none)')

    解决办法:

    找到工程目录的.git文件夹,打开之后找到config文件,在最后边加上一句话

    [user]

     email=your email

     name=your name

    your email 和your name随便写上就行

    OR

    git config --global user.email "you@domain.com"

    git config --global user.name "github_username"

    参考链接:http://stackoverflow.com/questions/25671785/git-fatal-unable-to-auto-detect-email-address

    github上传时出现error: src refspec master does not match any解决办法

    问题产生

    1. git服务器使用如下命令新建一个项目
    
    $ cd /opt/git
    $ mkdir project.git
    $ cd project.git
    $ git --bare init
    
    2. 客户端clone代码并提交
    
    $ cd myproject
    $ git init
    $ git add .
    $ git commit -m 'initial commit'
    $ git remote add origin git@gitserver:/opt/git/project.git
    $ git push origin master
    
    3. push报错

    原因分析

    引起该错误的原因是,目录中没有文件,空目录是不能提交上去的

    解决方法

    touch README
    git add README
    git commit -m 'first commit'
    git push origin master

    来自:http://www.open-open.com/lib/view/open1366080269265.html

    permission denied (publickey)问题的解决 和向github添加ssh key

    问题描述:

    使用ssh key这种方式进行clone ,pull github上面的项目,使用 git clone或者git pull origin master出现permission denied (publickey),原因是因为ssh key过期失效或者没有ssh key。 那么解决这种的问题的方法就是重新生成一个新的ssh key ,然后将这个ssh key添加到github账户上面,就可以了。

    解决步骤:

    (1) 检查SSH key是否已经存在

    ls ~/.ssh/ OR C:Users用户名.ssh/

    进行检查 id_rsa.pub 是否存在,如果存在,就不用生成一个新的SSH key了,直接跳到下面的第3步。

    (2)如果第1步中的SSH key不存在,生成一个新的SSH key

    命令如下:

    ssh-keygen -t rsa -b 2048 -C “your_email@example.com”

    其中,your_email@example.com要修改成你的邮箱地址。

    回车后输出如下:

    Generating public/private rsa key pair.
    
    Enter file in which to save the key (/home/xxx/.ssh/id_rsa):

    其中,xxx是你的用户名,直接回车,会将key保存到默认文件中。

    接着会输出:

    Enter passphrase (empty for no passphrase):
    
    Enter same passphrase again:

    这两步是让你输入一个密码,以及确认密码,这个密码在你提交代码到Github时会用到

    回车后就提示成功了:

    Your identification has been saved in /home/xxx/.ssh/id_rsa.
    
    Your public key has been saved in /home/xxx/.ssh/id_rsa.pub.
    
    The key fingerprint is:
    
    01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com

    到这一步,你会发现 ~/.ssh/id_rsa.pub 文件已经生成了。

    (3)将SSH key添加到ssh-agent

    先确认ssh-agent处于启用状态:

    eval “$(ssh-agent -s)”

    输出类似于:

    Agent pid 32070

    然后将SSH key添加到ssh-agent:

    ssh-add ~/.ssh/id_rsa

    这时又会要你输入密码:

    Enter passphrase for /home/xxx/.ssh/id_rsa:

    输入刚才记起来的密码,然后回车

    (4)将SSH key添加到Github账户中

    这一步,不用像网上说的那么复杂,直接在打开id_rsa.pub这个文件(这就是我们刚刚生成的ssh key文件),一般大致路径如下(每个人电脑不同,路径也会不同):系统盘符 —- 用户名 —- 计算机用户名 —-.ssh ,在这里名就可以看到 id_rsa、id_rsa.pub 、known_host这三个文件,打开id_rsa.pub,将里面的内容原样全部复制起来。打开github.com,登入账户,点击头像旁边的下拉按钮,选择settings —- ssh and gpg keys —— new ssh key —- 粘贴 —- 保存。

    (5)保存后,就能在上面看见刚建立的ssh key,之后在git 客户端就能够使用了

    参考链接:https://blog.csdn.net/isunnyvinson/article/details/52598863

  • 相关阅读:
    古谚、评论与论断、名篇与名言
    重读《西游记》
    重读《西游记》
    命名之法 —— 时间、季节、地点
    命名之法 —— 时间、季节、地点
    文言的理解 —— 古时的称谓、别称、别名
    文言的理解 —— 古时的称谓、别称、别名
    Oracle GoldenGate for Oracle 11g to PostgreSQL 9.2.4 Configuration
    瀑布 敏捷 文档
    POJ 1325 ZOJ 1364 最小覆盖点集
  • 原文地址:https://www.cnblogs.com/zhaijiahui/p/9798457.html
Copyright © 2011-2022 走看看