Home > Development Tools > git > body text

git local setting password

WBOY
Release: 2023-05-17 12:51:07
Original
1623 people have browsed it

As developers, we often need to use git for version control. Usually we will push the code to the remote warehouse, and then we need to enter the username and password for verification. However, it is very troublesome to enter the username and password every time. Is there any way to simplify this process? This article will introduce how to set a git password locally to make your git use more convenient.

  1. Installing Git

First you need to make sure you have installed git. If you have not installed it yet, you can go to the official website to download the installation package and install it: https://git-scm .com/download

  1. Open Git Bash

Open the terminal and enter the command: Git Bash

  1. Set global user name and email

Enter the following commands in the terminal to set the global user name and email:

$ git config --global user.name "Your Name"
$ git config --global user.email "your.email@example.com"
Copy after login
  1. Generate SSH key

If you have not generated an SSH key yet , you can skip this step. Otherwise, enter the following command in the terminal to generate the SSH key:

$ ssh-keygen -t rsa -C "your.email@example.com"
Copy after login

Enter the password as prompted, or just press Enter to skip the password setting.

  1. Set up password caching

In git, there are two ways to cache passwords locally: using git's credential helper, or using an SSH agent. Here we will introduce the first way.

Enter the following command in the terminal:

$ git config --global credential.helper cache
Copy after login

This will turn on password caching and set the default caching time to 15 minutes. If you need to customize the time, you can add parameters at the end, in seconds. For example, if it is set to 30 minutes, enter the following command:

$ git config --global credential.helper 'cache --timeout=1800'
Copy after login
  1. Enter password verification

Complete After the above settings, when you perform git operations again, you will see a prompt similar to the following:

$ git push
Username for 'https://github.com': your_username
Password for 'https://your_username@github.com':
Copy after login

At this time, you only need to enter the password once, and then git will cache the password. When you execute a similar command again, No need to enter password anymore.

  1. Clear Cache

If you want to clear the password cache, you can enter the following command:

$ git config --global --unset credential.helper
Copy after login

This will disable password caching.

Summary

Through the introduction of this article, you have learned how to set the git password locally to make your git use more convenient. Of course, to ensure account security, we do not recommend permanently saving passwords locally. If you are using a public computer, use caution.

The above is the detailed content of git local setting password. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!