Search code examples
gitgithubcygwin

Cygwin can't pull and push code


I can pull code with Git Bash, and it is asking for a username and password for the github. When I was trying to do this in Cygwin, the git status works but the pull will just hanging there. It is not asking me the username and password either. The machine I am using maybe has already configured by someone else. If the username and password has already been setup and it is not correct, could this be the reason it is not working. I search on the internet to find how to change the default settings, but looks like there is no proper answer I could get. I am new to this and still learning. Thank you for your help.


Solution

  • This is at least partially documented on GitHub Help.

    Why is Git always asking for my password?

    If git prompts you for a username and password instead of your SSH key passphrase, you’re using the HTTPS clone URL for your repository.

    Why not use HTTPS?

    HTTPS has some advantages. It’s easier to set up than SSH and usually works through strict firewalls and proxies. You can even set git to store your password so you don't have to enter it every time. If you'd like to set that up, make sure you've upgraded to the latest version of git and check out this guide.

    Switch to SSH via the command line

    To change the URL via the command line:

    1. Open the repository on github.com
    2. Click the copy button next to the SSH clone URL
    3. Open a command line and run git remote set-url origin with the new URL

    git remote set-url origin [email protected]:user/repo.git

    Make sure you have an SSH key that is recognized by the particular repository you are trying to access.