将项目从Android Studio推送到GitHub失败

时间:2020-09-23 10:55:39

标签: android-studio github

我试图将我的项目从android studio推送到GitHub,但是失败了。 这是错误:

Can't finish GitHub sharing process
            Successfully created project 'BurgerRating' on GitHub, but initial commit failed:
            *** Please tell me who you are.
            
            Run
            
            git config --global user.email "you@example.com"
            git config --global user.name "Your Name"
            
            to set your account's default identity.
            Omit --global to set the identity only in this repository.
            
            unable to auto-detect email address (got 'valk@DESKTOP-59LAKG3.(none)')

我不知道如何直接将项目推送到GitHub,因为它说该项目有100多个文件。请帮忙!

2 个答案:

答案 0 :(得分:1)

您所显示的错误只是在告诉您,您的git上没有标识您。建议您通过

解决
function show_recent_posts($atts, $content = null) {
 
  global $post;

  $html = "";

  $my_query = new WP_Query( array(
       'post_type' => 'post',
       'posts_per_page' => 1
  ));

  if( $my_query->have_posts() ) : while( $my_query->have_posts() ) : $my_query->the_post();

       $html .= "<h2>" . get_the_title() . " </h2>";
       $html .= "<p>" . get_the_excerpt() . "</p>";
       $html .= "<a href=\"" . get_permalink() . "\" class=\"button\">Read more</a>";

  endwhile; endif;

  return $html;
 }
add_shortcode('show_recent_posts', 'show_recent_posts')

您可以先按照该说明操作,然后显示接下来会发生什么情况

答案 1 :(得分:0)

对我来说,以下是有效的。请注意,我使用的是 Windows10 和两步验证。

  1. 通过以下方式获取 github 的个人访问令牌:
    设置 -> 开发者设置 -> 个人访问令牌

  2. 通过以下方式将令牌保存在 .gitconfig 中:

    git config --global user.name "your username"
    git config --global user.password "your github access token"

请注意,这将更改存储在以下位置的全局设置:

C:\Users\{your windows user name}\.gitconfig  

您最好保存此文件的备份。

  1. 在 Android Studio 上,转到 Settings -> Version Control -> Git 并设置 git 可执行路径。
  2. 在 Android Studio 上,转到 Settings -> Version Control -> GitHub 并单击 + 或按 Alt+Insert 然后选择 {{1}并粘贴我们在步骤 1 中生成的 Github 令牌。
  3. 在 Android Studio 的顶部菜单栏中,转到 Login with token -> VCS -> Import into version control 并共享项目。
  4. 我们看到一条错误消息,指出项目已创建但初始提交失败。现在转到 Share project on Github -> VCS 并删除原点。
  5. 使用 URL Remotes 添加 origin,通常用于克隆存储库。
  6. 现在您可以提交和推送了。转到 https://github.com/{your github user name}/{repository name}.git -> VCS -> Git