“Nothing to push” error in Android studio with 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 choose master as that alternative.It's because master is not created yet (repo is really 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"


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值