日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

mac下git与github简单使用

發(fā)布時(shí)間:2025/4/16 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mac下git与github简单使用 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

準(zhǔn)備工作:

下載安裝git客戶端?http://code.google.com/p/git-osx-installer/downloads/list?can=3 注冊(cè)github賬號(hào)?https://github.com/ -->Pricing and Signup -->Create a free account 創(chuàng)建ssh: 在local打開(kāi)terminal: $cd ~/.ssh ?檢查是否已經(jīng)存在ssh 如果存在,先將已有的ssh備份,或者將新建的ssh生成到另外的目錄下 如果不存在,通過(guò)默認(rèn)的參數(shù)直接生成ssh 生成過(guò)程如下: $ssh-keygen -t rsa -C xxxxx@gmail.com(注冊(cè)github時(shí)的email) Generating public/private rsa key pair. Enter file in which to save the key (/Users/twer/.ssh/id_rsa):? Created directory '/Users/twer/.ssh'. Enter passphrase (empty for no passphrase):? Enter same passphrase again:? Your identification has been saved in /Users/twer/.ssh/id_rsa. Your public key has been saved in /Users/twer/.ssh/id_rsa.pub. The key fingerprint is: 18:16:11:c9:01:6c:48:09:7f:27:c6:43:0d:7f:3f:84 xxxxx@gmail.com The key's randomart image is: +--[ RSA 2048]----+ |.o.++=== ? ? ? ? | |.ooo.+. . ? ? ? | | ?..* = E . ? ? ?| | ? o = + o ? ? ? | | ? ? ?. S o ? ? ?| | ? ? ? ? ? . ? ? | | ? ? ? ? ? ? ? ? | | ? ? ? ? ? ? ? ? | | ? ? ? ? ? ? ? ? | +-----------------+ 如果要修改ssh生成目錄,在藍(lán)色位置處輸入要生成的路徑,選擇默認(rèn)的話,會(huì)生成在 ~/.ssh下 在github中添加ssh: 登陸github,選擇Account Settings-->SSH Public Keys 添加ssh Title:xxxxx@gmail.com Key:打開(kāi)你生成的id_rsa.pub文件,將其中內(nèi)容拷貝至此 測(cè)試SSH: $ssh git@github.com The authenticity of host 'github.com (207.97.227.239)' can't be established. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)??yes Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts. PTY allocation request failed on channel 0 Hi xianfuying! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed. 在藍(lán)色位置處輸入 yes 設(shè)置本地git個(gè)人信息: $git config --global user.name "your real name" $git config --global user.email "xxxxx@gmail.com" 至此,git和github的設(shè)置就完成了,下面就是如何將本地代碼push到github上,以及如何從github上pull代碼了: 在github中創(chuàng)建Repository: https://github.com/ --> New Repository 輸入Repository信息 projectName 在本地創(chuàng)建代碼庫(kù): 創(chuàng)建一個(gè)文件夾作為local repository $mkdir test 創(chuàng)建一個(gè)文件 $cd test $vi test.txt 將文件添加至local repository $git add test.txt 初始化local repository $git init commit文件 $git commit -a 定義遠(yuǎn)程服務(wù)器別名 $git remote add alias git@github.com:xxxxx/projectName.git 將本地?cái)?shù)據(jù)push到github上 $git push alias master 這樣就可以將本地的代碼push到github的repository中了 從github中pull代碼: 在github中搜到你想要pull的代碼,如https://github.com/edgecase/ruby_koans 選擇fork,將此repository fock到你的repository下 在本地創(chuàng)建local repository并初始化 使用命令: $git pull git@github.com:xxxxx/ruby_koans.git 將github上的代碼pull到local repository中 參考: http://apps.hi.baidu.com/share/detail/16068052 http://blog.csdn.net/banxi1988/article/details/6555293 http://apps.hi.baidu.com/share/detail/31697631

轉(zhuǎn)載于:https://www.cnblogs.com/greywolf/archive/2013/01/28/2879479.html

總結(jié)

以上是生活随笔為你收集整理的mac下git与github简单使用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。