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