git Android Studio:推送到 GitHub 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34184633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:37:31  来源:igfitidea点击:

Android Studio: push to GitHub repository

androidgitgithubpush

提问by Wickerman

I want to be able to use the GitHub integration in Android Studios. I've made a project and I've done all the login-stuff you need to do in order to connect to your GitHub-account.

我希望能够在 Android Studios 中使用 GitHub 集成。我已经创建了一个项目,并且已经完成了连接到 GitHub 帐户所需的所有登录操作。

In Android Studios, I click on VCS -> Import Into Version Control -> Share Project on GitHub.

在 Android Studios 中,我单击 VCS -> 导入到版本控制 -> 在 GitHub 上共享项目。

Following question comes up:
Project is already on GitHub
Can't connect to repository from configured remote. You could want to check .git config. Do you want to proceed anyway?

出现以下问题:
项目已经在 GitHub 上
无法从配置的远程连接到存储库。您可能想要检查 .git 配置。您仍要继续吗?

If I click 'Yes', I can continue to fill in a new repository and description.

如果我单击“是”,我可以继续填写新的存储库和描述。

I get the following warning:
"Can't add remote fatal: remote github already exists. during executing git -c core.quotepath=false remote add github https://github.com/Wickerman2/Test2.git"

我收到以下警告:
“无法添加远程致命:远程 github 已经存在。在执行期间 git -c core.quotepath=false 远程添加 github https://github.com/Wickerman2/Test2.git

But I don't have any repositories! Android Studios only creates the repository Test2 and won't push any files!

但是我没有任何存储库!Android Studios 只创建存储库 Test2,不会推送任何文件!

回答by Durican Radu

The cleanest way to do it is the following:

最干净的方法如下:

  1. Make directory anywhere in your computer
  2. Change to that specific directory
  3. List item Git Clone that project that is already on github git clone [email protected]:foobar
  4. Copy-Paste your Android Studio project there
  1. 在计算机中的任何位置创建目录
  2. 更改到该特定目录
  3. 列出项目 Git Clone 已经在 github 上的项目 git clone [email protected]:foobar
  4. 在那里复制粘贴你的 Android Studio 项目

Now you should be able to use the version control.

现在您应该可以使用版本控制了。

回答by piotrek1543

It seems to be that you created a remote repository before you wanted to share it on Github.

似乎是您在想在 Github 上共享之前创建了一个远程存储库。

I see two ways:

我看到两种方式:

  1. Push changed code to your existing repo choosing VCS -> Git -> Push
  2. Delete existing remote repo and try again to Share a project
  3. Close Android Studio. Download an existing GitHub project (you can download as zip and than unpack it), put it anywhere. Go to this folder, it seems to be an empty but it has already hidden .gitfolder. On Linux press Ctrl+Hto show hidden files and copy this folder to your project. At this time, just commit changes and push it to remote repository.
  1. 将更改的代码推送到您现有的回购选择 VCS -> Git -> Push
  2. 删除现有的远程仓库并重试 Share a project
  3. 关闭 Android Studio。下载现有的 GitHub 项目(您可以下载为 zip 文件,然后解压),将其放在任何位置。转到此文件夹,它似乎是一个空文件夹,但它已经隐藏了.git文件夹。在 Linux 上按Ctrl+H显示隐藏文件并将此文件夹复制到您的项目。这时候,只需提交更改并将其推送到远程存储库即可。

Show hidden files on Windows: http://www.technipages.com/show-hidden-files-windows

在 Windows 上显示隐藏文件:http: //www.technipages.com/show-hidden-files-windows

If you would like to learn a bit Git console, visit: https://try.github.io/levels/1/challenges/1

如果你想学习一点 Git 控制台,请访问:https: //try.github.io/levels/1/challenges/1

Already I more times use console than Android Studio Github Integration, cause the second ones sometimes freezes and cannot force some actions.

我已经更多次使用控制台而不是 Android Studio Github 集成,导致第二个有时会冻结并且无法强制执行某些操作。