Git bash avoids repeatedly entering user names and passwords during push

Source: Internet
Author: User
Tags touch command

I use the Windows system, these days learned to use Git to find each use of Git push each time to enter the user name and password, feel very annoying, deliberately surf the internet, found a simplified method. Although not original, but at least added a bit of their own experience, after all, the middle also luo a half-day.

First enter your user name directory , Windows is generally in C:\users\Administrator, you need to create a new file named . git-credentials , Windows itself does not allow directly created to "." The beginning of the file/folder, need to rely on other tools, because later still want to use Git to configure the information, here is directly with the git Touch command. Open git bash and go to the user name directory you just said, execute the following command;

Touch. Git-credentialsvim. git-credentialshttps://{username}:{password} @github. com

Note: The first line is used to create the file. Git-credentials, the second sentence is to use the GIT bash built-in vim tool to edit this file (as if it was about formatting or how, I tried to create and edit it directly with sublime, but the results didn't work). Note here that after entering vim, you need to press "a" into edit mode , type git information in the third line of the template, such as my git is little-snow, if the password is 123456, type Https://{little-snow} : {123456} @github. com, then press ESC to exit edit mode , and then enter : wq! (wq! is save and exit, Vim is also a q!, do not save the direct exit), go back to git bash, and then enter the following command:

git config--global credential.helper store

Restart Git bash at this point, and then use push to not enter a username and password.

  Attention!!! Although this method can make push easier, but there are some drawbacks, that is, it will put your git username and password into an explicit file, open the file can be seen, so it is not safe, if you mind this point, please find another way!

Git bash avoids repeatedly entering user names and passwords during push

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.