在git push / pull命令上跳过输入用户名和密码 [英] Skip typing username and password on git push/pull commands

查看:374
本文介绍了在git push / pull命令上跳过输入用户名和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道如何设置它,所以当我在命令行,当我 push / pull 到/从一个git仓库我不必键入我的用户名和密码?



感谢。

解决方案

> http / https 作为您的传输协议,您将需要 username &



切换到ssh密钥,您将不再被询问。



下面的示例是如何设置GitHub的密钥,但对于大多数具有小更改(GUI)的服务器,我将是相同的。



流程仍然相同




  • 生成ssh键

  • 添加键

更改协议为ssh( git://




以下是设置方法: >


  • 生成新的ssh密钥(如果您已有密钥,请跳过此步骤

    ssh-keygen -t rsa -Cyour @ email


  • home / .ssh 目录(或 Users /< your user> .ssh 在Windows下),打开它并将内容复制到中央存储库下的相关部分(ssh键)。




< hr>

有关传输协议的更多信息,请阅读:





  • 点击 SSH密钥和GPG密钥 br>

  • 点击新SSH密钥 >

  • 粘贴您的密钥并保存



现在应该可以了。






/ code>



第一次设置打开终端并运行 git fetch ,因此键将被测试并添加到您的已知主机文件。


Anyone know how to set it up so when I'm in the command line and when I push/pull to/from a git repository I don't have to type in my username and password?

Thanks.

解决方案

When you use http/https as your transfer protocol you will be asked for username & password every time.

Switch to ssh key and you will not be asked anymore.

The sample below is how to set the key for GitHub, but i will be same for most of the servers with a minor changes (GUI).

The process is still the same

  • Generate ssh-key
  • Add the key to the server
  • Change the protocol to ssh (git://)

Here is how to set it up:

  • Generate a new ssh key (or skip this step if you already have a key as you mentioned )
    ssh-keygen -t rsa -C "your@email"

  • Once you have your key set in home/.ssh directory (or Users/<your user>.ssh under windows), open it and copy the content to the relevant section (ssh keys) under your central repository.


For more information about the transport protocols read this:


How to set up ssh key under your GitHub account?

  • Login to GitHub account
  • Click on the rancher on the top right (Settings)
  • Click on the SSH keys and GPG Keys
  • Click on the New SSH key
  • Paste your key and save

Now it should work


Note

After the first set up open terminal and run a git fetch so the key will be tested and added to your known hosts file.

这篇关于在git push / pull命令上跳过输入用户名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆