如何使用 Android Studio 的 github 功能

How to use GitHub with Android Studio

This article will explain how to use GitHub withAndroidStudio.

Firstly, let’s login togithub.comand create a new repository. From the top right corner of the screen, click the+sign and selectNew repository.

Now complete the form to create a new repository calledtestproject. Leave theInitialize this repository with a READMEunticked.

Next, openAndroid Studioand create a new project. Call your new applicationTestProject. ClickNextto continue.

Leave the next page as default?and clickNext.

On theAdd an activity to Mobilescreen selectBlank Activityand clickNext.

In the next screen, leave the default?activity name of MyActivity and click Finish.

Your new project will open in Android Studio. On the top menu, selectVCS>Import into Version Control>CreateGitRepository.

On the next screen, leave it all as default and clickOK.

Now use Internet Explorer and navigate to the root of your projects folder. Right click and selectGit Bash(If you do not see this option, then first installGit for Windows).

When the Git bash screen appears, type:

1

git remote add origin?https://github.com/[username]/[project_name].git

An example of a Git repository URL is:https://github.com/markwint/testproject.git

Then press enter. The GitHub remote will be added to your Git repository.

Next, jump back into Android Studio, right click your projects root directory and selectGit>Add. This will add all your project files to your Git repository.

It will seem like nothing has happened, but trust me, the project files are added.

Now right click the project name again and this time selectGit>Commit Directory.

In the next screen, type aCommit Messageand selectCommit.

If a Code Analysis warning appears, clickCommit. (Unless it’s a real project, in which case review and fix the issue before committing!)

Now, right click the project name, selectGit>Repository>Push.

Check the boxPush current branch to alternative branchand leave the branch name asmaster. Then selectpush.

Now enter your GitHubLogin(email address)?andPassword. Then clickOK.

If it’s all good, you will see this message.

Now your code is pushed to your GitHub repository. Don’t believe me? Logon and check for yourself.

上述轉(zhuǎn)自:http://blog.csdn.net/ganshuyu/article/details/41965853

還有篇不錯(cuò)的教程:http://blog.csdn.net/gao_chun/article/details/49817229/

注:

1友存、在? git remote add originhttps://github.com/[username]/xxx.git? 連接遠(yuǎn)程庫(kù)使可能會(huì)報(bào)錯(cuò)

fatal: remote origin already exists. 再悼,此時(shí)可以先

? ? ?(1)先刪除遠(yuǎn)程 Git 倉(cāng)庫(kù)

? ? ? ? ? ? ?$ git remote rm origin

? ? ? (2)再添加遠(yuǎn)程 Git 倉(cāng)庫(kù)

? ? ? ? ? ? ? $git remote add originhttps://github.com/[username]/xxx.git

2缎除、在push時(shí)可能報(bào)錯(cuò)Push rejected: Push to origin/master was rejected

? ? ? 出現(xiàn)錯(cuò)誤的主要原因是github中的README.md文件不在本地代碼目錄中

可以通過(guò)如下命令進(jìn)行代碼合并【注:pull=fetch+merge]

git pull --rebase origin master

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市荒辕,隨后出現(xiàn)的幾起案子汗销,更是在濱河造成了極大的恐慌犹褒,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,406評(píng)論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件弛针,死亡現(xiàn)場(chǎng)離奇詭異叠骑,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)钦奋,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,732評(píng)論 3 393
  • 文/潘曉璐 我一進(jìn)店門座云,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人付材,你說(shuō)我怎么就攤上這事朦拖。” “怎么了厌衔?”我有些...
    開(kāi)封第一講書人閱讀 163,711評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵璧帝,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我富寿,道長(zhǎng)睬隶,這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書人閱讀 58,380評(píng)論 1 293
  • 正文 為了忘掉前任页徐,我火速辦了婚禮苏潜,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘变勇。我一直安慰自己恤左,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,432評(píng)論 6 392
  • 文/花漫 我一把揭開(kāi)白布搀绣。 她就那樣靜靜地躺著飞袋,像睡著了一般。 火紅的嫁衣襯著肌膚如雪链患。 梳的紋絲不亂的頭發(fā)上巧鸭,一...
    開(kāi)封第一講書人閱讀 51,301評(píng)論 1 301
  • 那天,我揣著相機(jī)與錄音麻捻,去河邊找鬼纲仍。 笑死,一個(gè)胖子當(dāng)著我的面吹牛贸毕,可吹牛的內(nèi)容都是我干的巷折。 我是一名探鬼主播,決...
    沈念sama閱讀 40,145評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼崖咨,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了油吭?” 一聲冷哼從身側(cè)響起击蹲,我...
    開(kāi)封第一講書人閱讀 39,008評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤署拟,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后歌豺,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體推穷,經(jīng)...
    沈念sama閱讀 45,443評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,649評(píng)論 3 334
  • 正文 我和宋清朗相戀三年类咧,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了馒铃。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,795評(píng)論 1 347
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡痕惋,死狀恐怖区宇,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情值戳,我是刑警寧澤议谷,帶...
    沈念sama閱讀 35,501評(píng)論 5 345
  • 正文 年R本政府宣布,位于F島的核電站堕虹,受9級(jí)特大地震影響卧晓,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜赴捞,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,119評(píng)論 3 328
  • 文/蒙蒙 一逼裆、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧赦政,春花似錦胜宇、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 31,731評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至然评,卻和暖如春仅财,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背碗淌。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 32,865評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工盏求, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人亿眠。 一個(gè)月前我還...
    沈念sama閱讀 47,899評(píng)論 2 370
  • 正文 我出身青樓碎罚,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親纳像。 傳聞我的和親對(duì)象是個(gè)殘疾皇子荆烈,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,724評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容

  • afinalAfinal是一個(gè)android的ioc,orm框架 https://github.com/yangf...
    passiontim閱讀 15,429評(píng)論 2 45
  • Lesson 3: Using GitHub to Collaborate 3.1 Creating a GitH...
    赤樂(lè)君閱讀 6,071評(píng)論 3 11
  • 希望大家多多支持
    懶癌患者2007閱讀 113評(píng)論 0 3
  • 今天想在這里立下flag,每天堅(jiān)持記錄所以說(shuō)所想憔购。 美女剛開(kāi)始想寫色情小說(shuō)到最后才發(fā)現(xiàn)自己只是想記錄所思所想宫峦,受之...
    你是少年的歡喜閱讀 107評(píng)論 0 0
  • 我們?nèi)怂惺芸嗟母淳褪莵?lái)自于不清楚自己是誰(shuí),而盲目地去攀附玫鸟、追求那些不能代表我們自己的東西导绷。 快樂(lè)是由外物引發(fā)的...
    EE_lessismore閱讀 618評(píng)論 0 0