“Nothing to push” error in Android studio with Git

來源:互聯網
上載者:User

標籤:android studio   git   

在Android studio下使用git

參考:http://www.tuicool.com/articles/V7j6Zfq

1.準備安裝 git :

sudo apt-get install git-core

參考:https://www.digitalocean.com/community/tutorials/how-to-install-git-on-ubuntu-12-04

在Android studio中設定git外掛程式:File->Setting->Version Control->Git, 然後可以點擊Test測試一下,如:那麼你就設定成功了。

2.初始化git項目(git init)

操作如下:VCS->Enable Control Integration->Select "Git".

3.為git添加remote

在這一步中,studio沒有為我們提供可視化的GUI,在terminal下將目錄切換到項目的目錄,然後輸入git添加remote的命令,例如:git remote add origin "https://github.com/xxx/xxx.git".

4.將代碼添加到VCS(git add)

選中要提交的檔案->VCS->Git->Add

5.提交變化(git commit)

VCS->Commit Changes在提交的時候可以選擇Commit and Push,就可以直接push到伺服器。

在第一次提交時可能會出現 “Nothing to push” 的問題

參考:http://stackoverflow.com/questions/15913669/nothing-to-push-error-in-intellij-with-git

因為第一次提交,repository為空白,沒有master,你需要 在push介面中最下方的checkbox上挑勾,選擇"Push current branch to alternative branch"並且填寫為master即可,這樣就能建立master,以後push就不需要checkbox了,除非添加新的分支。

When you push to an empty repository you must set on checkbox "Push current branch to alternative branch" and choosemaster as that alternative.It‘s because master is not created yet (repo isreally empty). But doing this way you can pretend to initialize the repository.

While that checkbox is off and repository is empty, IDEA can‘t push, because its interface must be safe and he will not just create new brach if the one in which you pushed last accidentally disappeared (or just not exist). You must force that "branch creation"


“Nothing to push” error in Android studio with Git

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.