github 使用总结-----转
轉(zhuǎn)自:?http://blog.csdn.net/hao1056531028/article/details/7767567
?
1.創(chuàng)建一個(gè)新的repository:
先在github上創(chuàng)建并寫(xiě)好相關(guān)名字,描述。
$cd ~/hello-world?? ? ? ?//到hello-world目錄
$git init? ? ? ? ? ? ? ? ? ? ?//初始化
$git add .?? ? ? ? ? ? ? ? ? //把所有文件加入到索引(不想把所有文件加入,可以用gitignore或add 具體文件)
$git commit?? ? ? ? ? ? ? //提交到本地倉(cāng)庫(kù),然后會(huì)填寫(xiě)更新日志(?-m “更新日志”也可)
$git remote add origin git@github.com:WadeLeng/hello-world.git?? ? ? ?//增加到remote
$git push origin master?? ?//push到github上
2.更新項(xiàng)目(新加了文件):
$cd ~/hello-world
$git add .?? ? ? ? ? ? ? ? ?//這樣可以自動(dòng)判斷新加了哪些文件,或者手動(dòng)加入文件名字
$git commit?? ? ? ? ? ? ?//提交到本地倉(cāng)庫(kù)
$git push origin master?? ?//不是新創(chuàng)建的,不用再add 到remote上了
3.更新項(xiàng)目(沒(méi)新加文件,只有刪除或者修改文件):
$cd ~/hello-world
$git commit -a?? ? ? ? ?//記錄刪除或修改了哪些文件
$git push origin master??//提交到github
4.忽略一些文件,比如*.o等:
$cd ~/hello-world
$vim .gitignore?? ? //把文件類(lèi)型加入到.gitignore中,保存
然后就可以git add . 能自動(dòng)過(guò)濾這種文件
5.clone代碼到本地:
$git clone?git@github.com:WadeLeng/hello-world.git
假如本地已經(jīng)存在了代碼,而倉(cāng)庫(kù)里有更新,把更改的合并到本地的項(xiàng)目:
$git fetch origin?? ?//獲取遠(yuǎn)程更新
$git merge origin/master?//把更新的內(nèi)容合并到本地分支
6.撤銷(xiāo)
$git reset
7.刪除
$git rm ?*?// 不是用rm
//------------------------------常見(jiàn)錯(cuò)誤-----------------------------------
1.$ git remote add?origin git@github.com:WadeLeng/hello-world.git
?
?錯(cuò)誤提示:fatal: remote origin already exists.
?解決辦法:$ git remote rm origin
?然后在執(zhí)行:$ git remote add origin git@github.com:WadeLeng/hello-world.git?就不會(huì)報(bào)錯(cuò)誤了
?2.?$ git push origin master
?錯(cuò)誤提示:error:failed to push som refs to
?解決辦法:$ git pull origin master?//先把遠(yuǎn)程服務(wù)器github上面的文件拉先來(lái),再push 上去。
?
本人遇到的還有一個(gè)錯(cuò)誤就是,工程傳進(jìn)github 了可是里頭缺少文件,
解決方法 $git add . ? ?(注意一點(diǎn) ?。 ?)表示添加所有文件,
?
?官方教程:
https://help.github.com/articles/create-a-repo
?
推薦教程:
找了幾篇關(guān)于github的教程,一步一步照葫蘆畫(huà)瓢 下面是兩個(gè)自我感覺(jué)不錯(cuò)的教程,其他的都太墨跡了,食之無(wú)味:
使用github管理iOS分布式項(xiàng)目開(kāi)發(fā)?http://www.cnblogs.com/516inc/archive/2012/03/28/2421492.html ? ? (比較詳細(xì))
tit /github 使用方法小記: ? ?http://like-eagle.iteye.com/blog/1317009
轉(zhuǎn)載于:https://www.cnblogs.com/mengyan/archive/2013/01/10/2855530.html
《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專(zhuān)家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的github 使用总结-----转的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: junit4 的使用 顺便理解Class
- 下一篇: [解决方案]sql server复制需要