【问题标题】:I want to push git easily [duplicate]我想轻松推送 git [重复]
【发布时间】:2023-04-06 00:29:01
【问题描述】:

我想在不输入用户名的情况下推送github并且每次都通过。

使用 Ubuntu 终端,git 每次都会询问我的用户名和密码,当我在 MacOS 中推送时,它没有发生。 我在下面设置了正确的全局设置。

git config --global user.name "username"  
git config --global user.email "my@email.com"

看到了,(Why Git is not allowing me to commit even after configuration?) 并尝试过

git config --unset --local user.name
git config --unset --local user.email

但是什么也没发生……请帮帮我。

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = https://github.com/username/sh
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

【问题讨论】:

  • user.nameuser.email 与身份验证无关。这些设置只是或创作信息。

标签: github


【解决方案1】:

您已经使用https 协议设置了您的 git 存储库:

[remote "origin"]
    url = https://github.com/kaede0902/sh

https 协议要求您每次都输入您的用户名和密码。您需要使用ssh 协议。为此,您需要先创建 SSH 密钥。我会推荐本指南:https://www.testingexcellence.com/install-git-mac-generate-ssh-keys/。对于您的用例,在运行 ssh-keygen -t rsa 时,不要输入密码。

然后,完成后,转到您的本地存储库并执行以下命令:

git remote set-url origin git@github.com:kaede0902/sh.git

或使用以下命令在其他地方重新克隆您的存储库:

git clone git@github.com:kaede0902/sh.git

【讨论】:

  • 我记得我在第一台 PC 上创建了 ssh 密钥!谢谢!!!但是我在 Macbook 中的博客存储库,似乎正在使用 https,因为`url = github.com/kaede0902/blog` 写在 /blog/.git/config
  • 我可以做到这一点。使用SSH。没有通行证和用户名
【解决方案2】:

您需要为 GitHub 设置 SSH 密钥。见How to connect to GitHub with SSH

【讨论】:

    猜你喜欢
    • 2020-07-01
    • 1970-01-01
    • 2021-05-20
    • 2012-05-02
    • 2021-02-22
    • 2014-03-15
    • 2011-08-09
    • 1970-01-01
    • 2021-08-31
    相关资源
    最近更新 更多