bash 如何将我的项目从 Android Studio 添加到我的 GitHub 页面?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23330825/
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-18 10:19:36  来源:igfitidea点击:

How do I add my project from Android Studio to my GitHub page?

androidgitbashgithubandroid-studio

提问by intA

I've been looking at some guides on how to do this but nothing I've tried is working. What I've done so far:

我一直在查看有关如何执行此操作的一些指南,但我尝试过的任何方法都不起作用。到目前为止我所做的:

  • Downloaded git for windows
  • enabled version control in android studio -> selected git -> pointed it to git.exe
  • hit 'Test', everything works fine
  • 已下载适用于 Windows 的 git
  • 在 android studio 中启用版本控制 -> 选择 git -> 将其指向 git.exe
  • 点击“测试”,一切正常

This is when I get confused. I now have to add the remote manually through git bash, so I open up a bash prompt and I'm not sure what to type there. I've tried things like:

这是我感到困惑的时候。我现在必须通过 git bash 手动添加遥控器,所以我打开了一个 bash 提示,但我不确定在那里输入什么。我试过这样的事情:

git remote add origin https://github.com/[username]/[projectname].gitgit remote add origin [email protected]:[username]/[projectname].gitfor both of these I get the error message "fatal: remote origin already exists"

git remote add origin https://github.com/[username]/[projectname].gitgit remote add origin [email protected]:[username]/[projectname].git对于这两种情况,我都收到错误消息“致命:远程源已经存在”

If these already exist then why do I not see the project listed on my github account? I've tried to do an initial push through android studio but I still don't see anything. Also, when I push through android studio it is as if everything is fine, I get no error messages.

如果这些已经存在,那么为什么我在我的 github 帐户中看不到该项目?我试图通过 android studio 进行初步推送,但我仍然没有看到任何东西。此外,当我通过 android studio 时,好像一切都很好,我没有收到任何错误消息。

回答by Eduardo Naveda

You have origin as a remote created already, just add your stuff to the staging area using git add .then use git commit -m 'your commit message'to commit your changes, then the most important part, PUSHyour master branch to your remote using git push origin master.

你有产地为远程已经建立,只需添加你的东西使用暂存区域git add .,然后使用git commit -m 'your commit message'提交更改,那么最重要的组成部分,PUSH你的主分支远程使用到git push origin master

You should read about the git workflow, here: http://git-scm.com/book/en/Getting-Started-Git-Basics, http://marklodato.github.io/visual-git-guide/index-en.html.

您应该在此处阅读有关 git 工作流程的信息:http: //git-scm.com/book/en/Getting-Started-Git-Basics、http: //marklodato.github.io/visual-git-guide/index- .html.

回答by Abhishek

1 Sign up and create a GitHub account in www.github.com.

1 在 www.github.com 注册并创建一个 GitHub 帐户。

2 Create the repository to add project

2 创建存储库以添加项目

3 In Android studio Go to VCS =>Enable the version control

3 在 Android Studio 中转到 VCS =>启用版本控制

Now the whole project will be red

现在整个项目都会变成红色

4 Go to terminal

4 前往终端

5 Type command 'git status' to check the project files status, now it show all files need to commit

5 输入命令'git status'检查项目文件状态,现在显示所有需要提交的文件

6 'git add .' to add all files to current push

6 'git add .' 将所有文件添加到当前推送

7 'git commit -m"your message for push"' Message for the push

7 'git commit -m"your message for push"' 推送消息

8 Set remote for the push VCS=>Git=>Remotes (Where to push )

8 设置远程推送 VCS=>Git=>Remotes(推送到哪里)

9 'git pull' to get latest code from server, for now skip this

9 'git pull' 从服务器获取最新代码,现在跳过这个

10 'git push --set-upstream origin master' command to push

10 'git push --set-upstream origin master' 命令推送

11 Add your credentials in authentication

11 在身份验证中添加您的凭据

Now your project is successfully uploaded to GitHub

现在您的项目已成功上传到 GitHub