首页 > 解决方案 > 将现有的 Android Studio 项目添加到现有的 GitHub 存储库

问题描述

我在 Android Studio 中创建了一个项目新项目,我想将它添加到当前为空的现有 GitHub 存储库中。

我已经尝试过这个问题的答案:Replace GitHub repository with a new Android Studio project while reserved old commits 但是一旦我进入决赛,git push我就会收到一条错误消息fatal: No configured push destination.

我也试过https://github.community/t5/How-to-use-Git-and-GitHub/How-to-link-an-existing-Android-Studio-Project-to-an-existing/td- p/1946但这会将项目上传到错误的 GitHub 帐户。我有两个 GitHub 帐户,我认为这是这个解决方案的问题,我已经注销了我不需要的帐户。

还有其他方法可以连接到现有的 GitHub 存储库吗?

标签: gitandroid-studiogithub

解决方案


很可能您忘记添加遥控器。您可以使用以下命令检查远程列表。

 git remote -v

如果不存在来源,请尝试使用以下命令添加遥控器:

git remote add <remote name> <remote url>

(远程 url 是你的仓库 url,例如:https://github.com/user/repo.git

然后您可以使用以下命令推送:

git push <remote name> <your branch name>

推荐阅读