好長(zhǎng)時(shí)間沒上來弄東西了,今天回來先開始弄下Git,之后再繼續(xù)寫uboot與kernel的編譯,在版本控制下更加宏觀地觀察每次的變化。
?
1、在ubuntu中安裝git
$ sudo apt-get install git git-core
2、配置本機(jī)的git
$ git config --global user.name " abcd " $ git config --global user.email abcd@efgh.com
3、生成密鑰
$ ssh-keygen -t rsa -C " abcd@efgh.com " // 郵箱同上
4、提交密鑰
vim /home/linx/. ssh /id_rsa.pub // 復(fù)制里面的密鑰
到github網(wǎng)頁(yè)中登陸自己的賬號(hào),然后再account setting中,找到SSH KEY講復(fù)制的密鑰加入(需要再次輸入github的密碼)
5、檢驗(yàn)是否鏈接上了github
$ ssh git@github.com // 正常情況下,回顯如下 PTY allocation request failed on channel 0 Hi plinx ! You ' ve successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed.
6、首次推送
$ mkdir tmp // 創(chuàng)建推送目錄 $ cd tmp // 進(jìn)入推送目錄 $ git init // 設(shè)置該目錄為推送 $ touch README // 生成readme $ git add README // 加入修改列表 $ git commit -m ' first commit ' // 遞交修改聲明 $ git remote add origin git@github.com:abcd/tmp.git // 為遠(yuǎn)程Git更名為origin $ git push -u origin master // 推送此次修改
然后各種問題從這里開始了,以下談一下解決的方法:
?
問題一:
ERROR: Repository not found.
這個(gè)問題是因?yàn)樵谀阃扑偷膅ithub賬戶中,并沒有這個(gè)Repository。
解決方法:
1)檢查自己的github中的Repository,檢查自己創(chuàng)建的目錄,必須要兩者一致;
2)先git clone下github中的Repository,然后再進(jìn)行更改,這樣就一定一致了。
問題二:
Agent admitted failure to sign using the key.
Permission denied (publickey)
這個(gè)問題是因?yàn)槟愕膕sh key并沒有加入到你想git的github賬戶的ssh key中,所以沒有訪問權(quán)限。
解決方法:
1)重新拷貝一份當(dāng)前的~/.ssh/id_rsa.pub中的ssh key到github中添加;
2)先刪除~/.ssh/in_rsa*文件,然后重新ssh-keygen一份sshkey來生成密鑰,然后復(fù)制到github,接著ssh鏈接github來檢驗(yàn)是否成功聯(lián)通。
問題三:
// 出現(xiàn)如下提示 ! [rejected] master -> master (non-fast- forward) error: failed to push some refs to ...
這個(gè)問題是因?yàn)椋琯ithub中已經(jīng)有了這個(gè)代碼,不允許你覆蓋它。
解決方法:
1)強(qiáng)制推送,一般不推薦!
$ git push -f
2)
$ git pull
然后將出現(xiàn)其他提示,具體意思是說branch與merge未指定,git無法選擇要推送的分支。
可以通過修改 .git/config文件中的下列內(nèi)容
[branch " master " ] remote = origin merge = refs/heads/master
也可以直接命令行修改
$ git config branch.master.remote origin
$ git config branch.master.merge ref
/heads/master
目前了解到的也就這三個(gè)問題了。
之后就可以成功得推送了。
?
?
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號(hào)聯(lián)系: 360901061
您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對(duì)您有幫助就好】元
