How do I update the password for Git?

1,099,655

Solution 1

To fix this on macOS, you can use

git config --global credential.helper osxkeychain

A username and password prompt will appear with your next Git action (pull, clone, push, etc.).

For Windows, it's the same command with a different argument:

git config --global credential.helper wincred

Solution 2

None of the other answers worked for me on MacOS Sierra 10.12.4

Here is what I had to do:

git config --global --unset user.password

Then run your git command (ex. git push) and reenter your username and password.

Solution 3

In Windows 10 with Git

Remove/update related Credentials stored in Windows Credentials in >>Control Panel\All Control Panel Items\Credential Manager

enter image description here

Solution 4

The only way I could modify my git password was to go to Credential Manager in Windows (Windows Key + type 'credential') and edit the git entry under Windows Credentials 🡒 Generic Credentials. Note: Not listed alphabetically

Solution 5

I had the same problem, and the accepted answer didn't help me because the password wasn't stored in the keychain. I typed:

git pull https://[email protected]/mypath/myrepo.git

Then console asked me for my new password.

Share:
1,099,655
Ken M. Haggerty
Author by

Ken M. Haggerty

I'm an intermediate programmer. I taught myself Objective-C for iOS so that I can better understand the work and frustrations that go into developing consumer software. My first iOS app is now on the Apple App Store! AppStore.com/Threeo I have previously played around with: MATLAB w/ Psychtoolbox • Python w/ PyQT • HTML / CSS / JS • Scheme w/ MIT-Church I am currently working on: • Akay, a crowdsourced data management app for iPhone and iPod touch • Updates to Threeo, including in-app purchasing and asynchronous multiplayer I know that I will never become an expert programmer but I hope to learn enough to be able to hold an intelligent conversation and work with interested programmers.

Updated on July 08, 2022

Comments

  • Ken M. Haggerty
    Ken M. Haggerty almost 2 years

    I'm using BitBucket with Xcode and Git for version control, and recently I changed all of my passwords (thanks Adobe!).

    Unsurprisingly, I'm no longer able to push my local commits to my repository on BitBucket (Authentication failed for 'https://______.git'), but I'm forgetting how to update the cached password on my iMac. Somehow I've been unable to find it on Google or Stack Overflow, though it seems to me it should be rather straightforward...

  • b_dubb
    b_dubb over 7 years
    On Mac OS 10.12.2 and when I did the above - checked and double checked that I entered it correctly - and nothing happened.
  • Anita Mehta
    Anita Mehta over 7 years
    I tried like this only but still credential pop is displaying, instead of reset password
  • rkd
    rkd almost 7 years
    Worked for me just now on 10.12.3 (Sierra). Had to do it twice though but that may have been a VPN/network issue
  • user2782001
    user2782001 almost 7 years
    @b_dubb It might not do anything until the next time you reach out (push, pull,fetch) then you will be prompted for credentials.
  • Fawwad
    Fawwad almost 7 years
    if i push from local to my remote server then which password i have to use ? Is this my remote server credential password or other ?
  • Pritam Banerjee
    Pritam Banerjee almost 7 years
    @Fawwad It's the password for the remote repository.
  • Fawwad
    Fawwad almost 7 years
    My remote server is not github.com. It is my dedicated server where i installed Git.
  • neuralmer
    neuralmer almost 7 years
    @user2782001 I was using the osxkeychain helper, running the mac command did nothing. I suspect that if someone was not using the helper before, changing the configuration to use the helper, it would see that a password had not been entered for that remote, it would prompt, and everything would be fine the first time. Subsequent changes of the configuration would not prompt. The answer below worked for me.
  • disklosr
    disklosr over 6 years
    Does not work on windows. Doesn't prompt for the new password
  • Coach Roebuck
    Coach Roebuck over 6 years
    This is what I chose to do. I had multiple github accounts stored in the Keychain. I chose to delete them all. Successfully pushed my local branch.
  • shdobxr
    shdobxr over 6 years
    This was the proper method that worked for me (on mac)
  • phocks
    phocks over 6 years
    Worked perfectly on Sierra. So silly that it doesn't just ask you to re-login. It just fails with a remote: Invalid username or password.
  • Joshua Eric Turcotte
    Joshua Eric Turcotte over 6 years
    This only worked for me (on sierra) up to the point where it began asking me for un/pw ... but it refuses to accept what I have demonstrated to myself over and over again to be the correct password. I do have two-factor enabled, so I have to assume it is involved, but I'm not being prompted for anything related to that.
  • fiskra
    fiskra over 6 years
    It worked for me, but I had to reset captcha first. Thank you.
  • cbloss793
    cbloss793 almost 6 years
    This saved me! I was storing it in composer, but it was also creating an auth.json which got annoying because I always forgot to add it to the .gitignore.
  • timwaagh
    timwaagh almost 6 years
    i understand how this would help you push the first time, but how this would help to update the saved password.
  • Saikat
    Saikat almost 6 years
    The question was asked for macOS
  • Michael
    Michael over 5 years
    @JoshuaEricTurcotte I know this is way late, but if you have two factor enabled you need to generate an API token from your account settings in GitHub and use that for your password. Instructions here: help.github.com/articles/…
  • Daniel Diehl
    Daniel Diehl over 5 years
    Did not work for me on macOS Sierra 10.12.6. git version 2.8.4
  • bgenchel
    bgenchel over 5 years
    This does not seem to do anything. OSX El Capitan. git version 2.7.4
  • Stefan Lasiewski
    Stefan Lasiewski over 5 years
    This is what worked for me! It allows us to update the password from one repo. Some of the other suggestions on this page will effect everything that git touches.
  • Paul Taylor
    Paul Taylor over 5 years
    Thankyou that worked ! before then it was prompting me for password but even though I entered new password authincation still failed.
  • Paul Solt
    Paul Solt over 5 years
    There is no visible immediate feedback, but it works on High Sierra. I had to clone a github repository before it actually asks for the password, it seems like it just sets a "dirty" flag for the next time you do a github request as @user2782001 mentioned.
  • chill appreciator
    chill appreciator over 5 years
    This do nothing for me on Windows. After this command I've tried to push, and it was successful, so the password is still available for git
  • dexter
    dexter over 5 years
    This was indeed the way. For users that have to work with the Dutch version of the OS: credentials ---> referentiebeheer
  • iheanyi
    iheanyi over 5 years
    @Saikat and yet, many of us with the same question for windows end up finding this SO question. It's almost as if the question itself while tagged macos isn't OS specific!
  • iheanyi
    iheanyi over 5 years
    @Fawwad it doesn't matter what you're using. You still need to give the credentials that provide write access to the repository to which you want to write.
  • John Lin
    John Lin about 5 years
    Worked for me on Win 10. Password prompt popped up and didn't need to go to Control Panel
  • nzrytmn
    nzrytmn about 5 years
    @halxinate which operating system you use ? This is for windows 10.
  • Kellen Stuart
    Kellen Stuart almost 5 years
    not a good answer. Re-cloning is way too much for this simple task
  • Kellen Stuart
    Kellen Stuart almost 5 years
    This was the only answer that worked for me on Win 10
  • yuva
    yuva almost 5 years
    This was the simplest solution. All you need to do is edit. Thanks.
  • Everts
    Everts almost 5 years
    Btw, the path for me was Control Panel\User Accounts\Credential Manager but best is to type Credential to jump right in.
  • Imran Javed
    Imran Javed almost 5 years
    @Everts what is OS of your machine?
  • codarrior
    codarrior almost 5 years
    For me the symptoms were showing like remote: repository not found just after I changed my Github user password on MacOS Mojave, I just followed the steps outlined here help.github.com/en/articles/…. Great help.
  • John Demetriou
    John Demetriou almost 5 years
    Well, calling the command git push (or pull) just gave me authentication error and access denied. Did not prompt me
  • Kevin Hooke
    Kevin Hooke almost 5 years
    Works on Mojave 10.14
  • Bonifacio2
    Bonifacio2 over 4 years
    This answer doesn't cover anything that isn't covered by Derek's.
  • Lavandysh
    Lavandysh over 4 years
    This way your password does get saved in history, and anyone who runs the history command can see it as plain text. To prevent it you can add an extra space before the command or run this command 'history -d 1234' with the right line ID afterwards
  • shemekh
    shemekh over 4 years
    Worked on Win10. Firstly I used command from this answer and later simply git pull - Windows popup appeared prompting for a password. Thanks!
  • Dhaval Patel
    Dhaval Patel over 4 years
    Thanks a lot! Save my day.
  • Sergei Emelianov
    Sergei Emelianov over 4 years
    Woks on mac, but you have to do smt after this command, for example git pull or git fetch, so that it will prompt you to enter and save a new password.
  • vlad
    vlad over 4 years
    Did not work for me. I have resolved the issue as described here: cmatskas.com/how-to-update-your-git-credentials-on-windows
  • Venkatesh Manohar
    Venkatesh Manohar over 4 years
    Works on Mac. Thanks :)
  • pinei
    pinei over 4 years
    warning: invalid credential line: ? fatal: unable to read credential from stdin
  • iphondroid
    iphondroid about 4 years
    After doing this if it says incorrect password on a push request, try pulling first to get a password prompt because this command only did unset the password.
  • pvill
    pvill about 4 years
    Worked for me on linux
  • Kamlesh
    Kamlesh about 4 years
    NOT WORKING DEAR, TRIED TWICE
  • nemnesic
    nemnesic about 4 years
    Just a friendly reminder not to use --global if you have different accounts for different repos
  • carlin.scott
    carlin.scott about 4 years
    My preferred method for opening anything on Windows, is to tap the Windows key and type the name of the thing in, and then press enter when it pops up in the search results. It's a lot faster and easier than navigating through explorer as suggested.
  • radzimir
    radzimir almost 4 years
    That worked for me under Windows 10, other methods not. This should be probably the correct answer.
  • radzimir
    radzimir almost 4 years
    Warning: this stores an UNENCRYPTED password in ~/.gitconfig.
  • Des Cahill
    Des Cahill almost 4 years
    Love it thanks for the help, knew there was an easier solution.
  • Denise Skidmore
    Denise Skidmore over 3 years
    You can just remove rather than edit, and you'll be prompted on the next push/pull
  • Yunzhao Xing
    Yunzhao Xing over 3 years
    This one works for me. In Win 10, you can simply search "windows credentials" in the task bar, then edit the item you want to.
  • f1v3
    f1v3 over 3 years
    Thanks for this! Worked perfectly on Windows 10 using mingw64.
  • ZuBsPaCe
    ZuBsPaCe over 3 years
    Thanks! I'm using git-fork and had to delete all credentials to our on-premise Azure Dev Ops server after Windows wanted me to change my domain password. Thereafter git push magically worked again without entering new credentials. Simply editing those credentials did not work.
  • Alexey Korkoza
    Alexey Korkoza about 3 years
    Also, this command worked on Windows 10, thank you very much.
  • Imran Javed
    Imran Javed about 3 years
    @ZuBsPaCe, some times you have to close related program (git, vs or etc) to get fresh data
  • Nicholas Obert
    Nicholas Obert about 3 years
    Works also on linux
  • Reed
    Reed about 3 years
    My credentials disappeared from here somehow, so I ran git fetch in one of my repos. Windows propmpted for authentication, and then populated the credentials here as expected.
  • John Fantastico
    John Fantastico about 3 years
    2021 and this still saved the day.
  • tok
    tok about 3 years
    This was the only solution that worked for me on Windows 7
  • Positive Navid
    Positive Navid almost 3 years
    It worked for windows 7 too (don't ask why our company is using ancient Windows)
  • Amal Kumar S
    Amal Kumar S almost 3 years
    This worked for two-factor authentication scenario.
  • Ray Depew
    Ray Depew almost 3 years
    This used to work, but it doesn't work anymore. @Dan Leonard's solution works well.
  • Hanane
    Hanane over 2 years
    This solution worked for me, none of those above did, I want to specify that USER is not the username that u use to access to ur github account, but the user of REPO
  • Marilynn
    Marilynn over 2 years
    This worked fine for me, just search for CredentialManager from the windows option and change/edit the password under Windows Credentials option. Thanks.
  • Neil Fraser
    Neil Fraser over 2 years
    Yes. This is the only solution that worked for me. One command one should run first is: git remote -v so that one can see the existing [USER] and [REPO] parameters.
  • yılmaz
    yılmaz over 2 years
    I ran command for Mac on Windows machine. It did not recognize the command but a popup opened to enter password, which I was looking for.
  • Dmitry Kabanov
    Dmitry Kabanov over 2 years
    @PritamBanerjee, how is this related to the question of OP?
  • Pritam Banerjee
    Pritam Banerjee over 2 years
    @DmitryKabanov read the whole answer on how I did reset the password
  • Herohtar
    Herohtar over 2 years
    This is the correct answer and works on all platforms.
  • Takatalvi
    Takatalvi over 2 years
    If you wanna add one credential, the Internet or network address should be something like git:https://yourrepo.address, then your username and pass for it.
  • Ousama
    Ousama over 2 years
    It works perfectly
  • Cadoiz
    Cadoiz over 2 years
    Could you add the source for your quote at the end?
  • Bazer Con
    Bazer Con over 2 years
    I updated your formatting tried to add the reference to Andrew Pye, but couldn't find something. Reformatting Renhuais comment: running git config --global --unset user.password and then git push origin master will ask you for username and password. Put that into the answer too?
  • Ian Warburton
    Ian Warburton over 2 years
    If the name of your personal access token is "token" and token value is "123" then [TOKEN] = token:123 . For github.com/[USER]/[REPO], copy the URL that points at your repository - everything after "https://".
  • Sam Soffes
    Sam Soffes over 2 years
    Exactly what I was looking for. Source for this is: docs.github.com/en/get-started/getting-started-with-git/…
  • Kamlesh
    Kamlesh about 2 years
    There is no git related generic credentials on my computer while I use git commit, push, pull everyday. Then how can we update the password? Please suggest. Thanks.
  • Kamlesh
    Kamlesh about 2 years
    There is no git related generic credentials on my computer while I use git commit, push, pull everyday. Then how can we update the password? Please suggest. Thanks.
  • Kamlesh
    Kamlesh about 2 years
    There is no git related generic credentials on my computer while I use git commit, push, pull everyday. Then how can we update the password? Please suggest. Thanks.
  • Gert
    Gert about 2 years
    In Visual Studio Code, the terminal command's did not do anything for me. Opening KeychainAccess (not Keychain) searching and deleting the entry fixed the problem. When using BitBucket, search for bitbucket instead of git.
  • Imran Javed
    Imran Javed about 2 years
    @Kamlesh, hope it is a case of credentials at repo instead of Global. If this is the case then it will ask you to reenter credentials in case of failure or you can change it through command directly. you can try >git credential reject
  • Kamlesh
    Kamlesh about 2 years
    @ImranJaved Thanks for your reply. You can check my issue at stackoverflow.com/questions/70913288/…
  • ThR37
    ThR37 about 2 years
    Does not work for me on Linux but might work on other platforms.
  • ThR37
    ThR37 about 2 years
    It worked for me! Thanks a lot!
  • Imran Javed
    Imran Javed about 2 years
    @Kamlesh, if you are stuck and there is no pending pull or push then I will recommend to refresh you repo clone.
  • Arash Kamangir
    Arash Kamangir about 2 years
    Windows solution worked for me (win10).
  • Kamlesh
    Kamlesh about 2 years
    @ImranJaved git pull / push / merge / commit all are working. But due to compromised my command line password, I want to change it. Not found any solution yet. Thanks a lot.
  • Eric Aig
    Eric Aig about 2 years
    This worked for me as well
  • Alex Christodoulou
    Alex Christodoulou about 2 years
    This should be the right answer for mac users, this is how mac manages passwords
  • MADHAIYAN M
    MADHAIYAN M about 2 years
    Its working in Mac too
  • Mario
    Mario about 2 years
    Indeed, this is the most portable and correct of all answers and should be the main answer to this question. It also worked for me under Linux. Thanks.
  • Chiarcos
    Chiarcos about 2 years
    --global should normally not be necessary.
  • Chiarcos
    Chiarcos about 2 years
    On Ubuntu 20.04, this did not immediately work as the username is lost and not automatically requested by the next git command. However, it worked seamlessly when the next command included the user name, so, e.g., git pull https://[email protected]/....
  • Plugie
    Plugie about 2 years
    Works for me on windows 10
  • grefel
    grefel almost 2 years
    In German Windows the Credential Manager is called "Anmeldeinformationsverwaltung"
  • Kh.Taheri
    Kh.Taheri almost 2 years
    worked on M1.. thanx