“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"
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。