Git change password for remote repository windows

I'm currently using GitHub over HTTPS and have the latest version of Git installed (1.9.0) along with the Git credential helper on Windows 7. On setting up my environment, I told git-credentials to

I’m currently using GitHub over HTTPS and have the latest version of Git installed (1.9.0) along with the Git credential helper on Windows 7.

On setting up my environment, I told git-credentials to permanently remember my username and password.

I’ve recently updated my GitHub password via the website and I’m now no longer able to push/pull/fetch, etc.

How I would go about updating my password on git-credentials helper on Windows 7?

Peter Mortensen's user avatar

asked Sep 15, 2014 at 10:29

Andrew Thomson's user avatar

Andrew ThomsonAndrew Thomson

4,4623 gold badges17 silver badges15 bronze badges

5

None of these answers ended up working for my Git credential issue. Here is what did work if anyone needs it (I’m using Git 1.9 on Windows 8.1).

To update your credentials, go to Control PanelCredential ManagerGeneric Credentials. Find the credentials related to your Git account and edit them to use the updated password.

Reference: How to update your Git credentials on Windows

Note that to use the Windows Credential Manager for Git you need to configure the credential helper like so:

git config --global credential.helper wincred

If you have multiple GitHub accounts that you use for different repositories, then you should configure credentials to use the full repository path (rather than just the domain, which is the default):

git config --global credential.useHttpPath true

Peter Mortensen's user avatar

answered Oct 2, 2017 at 18:41

xgo's user avatar

12

On my first attempt to Git fetch after my password change, I was told that my username/password combination was invalid. This was correct as git-credential helper had cached my old values.

However, I attempted another git fetch after restarting my terminal/command-prompt and this time the credential helper prompted me to enter in my GitHub username and password.

I suspect the initial failed Git fetch request in combination with restarting my terminal/command-prompt resolved this for me.

I hope this answer helps anybody else in a similar position in the future!

Peter Mortensen's user avatar

answered Sep 15, 2014 at 11:16

Andrew Thomson's user avatar

Andrew ThomsonAndrew Thomson

4,4623 gold badges17 silver badges15 bronze badges

6

If you are a Windows user, you may either remove or update your credentials in Credential Manager.

In Windows 10, go to the below path:

Control PanelAll Control Panel ItemsCredential Manager

Or search for «credential manager» in your «Search Windows» section in the Start menu.

Then from the Credential Manager, select «Windows Credentials».

Credential Manager will show many items including your outlook and GitHub repository under «Generic credentials»

You click on the drop down arrow on the right side of your Git: and it will show options to edit and remove. If you remove, the credential popup will come next time when you fetch or pull. Or you can directly edit the credentials there.

Peter Mortensen's user avatar

answered Oct 23, 2018 at 19:27

Vins's user avatar

VinsVins

1,89116 silver badges14 bronze badges

5

Solution using command line for Windows, Linux, and MacOS

If you have updated your GitHub password on the GitHub server, in the first attempt of the git fetch/pull/push command it generates the authentication failed message.

Execute the same git fetch/pull/push command a second time and it prompts for credentials (username and password). Enter the username and the new updated password of the GitHub server and login will be successful.

Even I had this problem, and I performed the above steps and done!!

Peter Mortensen's user avatar

answered Oct 13, 2016 at 5:18

Farooque's user avatar

FarooqueFarooque

3,5461 gold badge29 silver badges40 bronze badges

8

First find the version you are using with the Git command git --version. If you have a newer version than 1.7.10, then simply use this command:

git config --global credential.helper wincred

Then do the git fetch , then it prompts for the password update.

Now, it won’t prompt for the password for multiple times in Git.

answered Nov 17, 2015 at 20:48

Sireesh Yarlagadda's user avatar

5

It seems to me that the answers here are outdated. For me using Git v2.15.0 issuing git credential reject like this did the job:

$ git credential reject
protocol=https
host=github.com
<Empty line here>

And then to set the new username & password:

$ git credential fill
protocol=https
host=github.com
<empty line here>

After this, if the credentials now work on the desired target host, we should use git credential approve -as mentioned in typical use of Git credentials (step 4)- to tell the credential helpers to mark the credentials as approved and reuse them in future connections.

answered Nov 21, 2017 at 13:10

atavio's user avatar

atavioatavio

1,11513 silver badges19 bronze badges

10

FWIW, I stumbled over this very same problem (and my boss too, so it got more intense).

The instant solution is to delete or fix your Git entries in the Windows Credential Manager. You may have a hard time finding it in your localized Windows version, but luckily you can start it from the good old Windows + R run dialog with control keymgr.dll or control /name Microsoft.CredentialManager (or rundll32.exe keymgr.dll, KRShowKeyMgr if you prefer the classic look). Or put this in a batch file for your colleagues: cmdkey /delete:git:http://your.git.server.company.com.

In Microsoft’s Git Credential Manager this is a known issue that may be fixed as soon as early 2019 (so don’t hold your breath).

Update (2020-09-30): GCM4W seems to be more or less abandoned (last release more than a year ago, only one commit to master since then named, I kid you not, «Recreate the scalable version of the GCM Logo»). But don’t despair, with Microsoft now going Core, there is a shiny new project called GCM Core, which seems to handle password changes correctly. It can be installed standalone (should be activated automatically, otherwise activate e.g. with git config --system credential.helper manager-core) but is also included in the current Git for Windows 2.28.0. For more information about it, see this blog post.

answered Nov 29, 2018 at 14:56

Jakob's user avatar

JakobJakob

6316 silver badges11 bronze badges

3

Working solution for Windows:

Control Panel > User Accounts > Credential Manager > Generic Credentials

enter image description here

answered Sep 14, 2020 at 3:18

Waqas Ahmed's user avatar

Waqas AhmedWaqas Ahmed

1,6601 gold badge14 silver badges15 bronze badges

3

Just cd in the directory where you have installed git-credential-winstore. If you don’t know where, just run this in Git Bash:

cat ~/.gitconfig

It should print something looking like:

[credential]
    helper = !'C:\ProgramFile\GitCredStore\git-credential-winstore.exe'

In this case, you repository is C:ProgramFileGitCredStore. Once you are inside this folder using Git Bash or the Windows command, just type:

git-credential-winstore.exe erase
host=github.com
protocol=https

Don’t forget to press Enter twice after protocol=https.

Peter Mortensen's user avatar

answered Jun 2, 2015 at 9:52

Luc DUZAN's user avatar

Luc DUZANLuc DUZAN

1,2799 silver badges18 bronze badges

None of the current solutions worked for me with git bash 2.26.2.
This should work in any case if you are using the windows credential manager.

One issue is the windows credential manager runs for the logged user. In my case for example, I run git bash with right click, run as admin. Therefore, my stored credentials are in a credentials manager which I can’t access with the windows GUI if I don’t login to windows as admin.

To fix this:

  • Open a cmd as admin (or whatever user you run git bash with)
  • Go to windows/system32
  • Type cmdkey /list. Your old credentials should appear here, with a part that reads …target:xxx
  • Type cmdkey /delete:xxx, where xxx is the target from the previous line

It should confirm you that your credentials have been removed. Next time you do any operation in git bash that requires authentication, a popup will ask for your credentials.

answered May 22, 2020 at 9:48

Jorge.V's user avatar

Jorge.VJorge.V

1,3191 gold badge14 silver badges19 bronze badges

1

For Windows 10 it is:

Control Panel > User Accounts > Manage your Credentials > Windows Credentials, search for the git credentials and edit

answered Dec 17, 2020 at 21:56

htafoya's user avatar

htafoyahtafoya

17.6k11 gold badges76 silver badges100 bronze badges

1

If you have reset your password, hence you are getting Auth failure error in the git bash command window. (it does not show popup where you could enter new password).

In the git bash cmd window enter following command:

$ git config --global credential.helper wincred

Some times it will show popup to enter the new password
or Sometimes popup will be displayed when you are trying to do $git clone ..command

answered Sep 14, 2021 at 16:28

Barani r's user avatar

Barani rBarani r

1,9731 gold badge23 silver badges24 bronze badges

If you keep getting «fatal: Authentication failed for «https://……git» and you are unable to update the password.

  1. $ git config —global credential.helper wincred
  2. git clone -b ..git
  3. Popup will be displayed for username password
  4. enter the new password

answered Dec 5, 2022 at 16:23

Barani r's user avatar

Barani rBarani r

1,9731 gold badge23 silver badges24 bronze badges

NAME

gitfaq — Frequently asked questions about using Git

SYNOPSIS

DESCRIPTION

The examples in this FAQ assume a standard POSIX shell, like bash or dash,
and a user, A U Thor, who has the account author on the hosting provider
git.example.org.

Configuration

What should I put in user.name?

You should put your personal name, generally a form using a given name
and family name. For example, the current maintainer of Git uses «Junio
C Hamano». This will be the name portion that is stored in every commit
you make.

This configuration doesn’t have any effect on authenticating to remote services;
for that, see credential.username in git-config[1].

What does http.postBuffer really do?

This option changes the size of the buffer that Git uses when pushing
data to a remote over HTTP or HTTPS. If the data is larger than this
size, libcurl, which handles the HTTP support for Git, will use chunked
transfer encoding since it isn’t known ahead of time what the size of
the pushed data will be.

Leaving this value at the default size is fine unless you know that either the
remote server or a proxy in the middle doesn’t support HTTP/1.1 (which
introduced the chunked transfer encoding) or is known to be broken with chunked
data. This is often (erroneously) suggested as a solution for generic push
problems, but since almost every server and proxy supports at least HTTP/1.1,
raising this value usually doesn’t solve most push problems. A server or proxy
that didn’t correctly support HTTP/1.1 and chunked transfer encoding wouldn’t be
that useful on the Internet today, since it would break lots of traffic.

Note that increasing this value will increase the memory used on every relevant
push that Git does over HTTP or HTTPS, since the entire buffer is allocated
regardless of whether or not it is all used. Thus, it’s best to leave it at the
default unless you are sure you need a different value.

How do I configure a different editor?

If you haven’t specified an editor specifically for Git, it will by default
use the editor you’ve configured using the VISUAL or EDITOR environment
variables, or if neither is specified, the system default (which is usually
vi). Since some people find vi difficult to use or prefer a different
editor, it may be desirable to change the editor used.

If you want to configure a general editor for most programs which need one, you
can edit your shell configuration (e.g., ~/.bashrc or ~/.zshenv) to contain
a line setting the EDITOR or VISUAL environment variable to an appropriate
value. For example, if you prefer the editor nano, then you could write the
following:

If you want to configure an editor specifically for Git, you can either set the
core.editor configuration value or the GIT_EDITOR environment variable. You
can see git-var[1] for details on the order in which these options are
consulted.

Note that in all cases, the editor value will be passed to the shell, so any
arguments containing spaces should be appropriately quoted. Additionally, if
your editor normally detaches from the terminal when invoked, you should specify
it with an argument that makes it not do that, or else Git will not see any
changes. An example of a configuration addressing both of these issues on
Windows would be the configuration "C:Program FilesVimgvim.exe" --nofork,
which quotes the filename with spaces and specifies the --nofork option to
avoid backgrounding the process.

Credentials

How do I specify my credentials when pushing over HTTP?

The easiest way to do this is to use a credential helper via the
credential.helper configuration. Most systems provide a standard
choice to integrate with the system credential manager. For example,
Git for Windows provides the wincred credential manager, macOS has the
osxkeychain credential manager, and Unix systems with a standard
desktop environment can use the libsecret credential manager. All of
these store credentials in an encrypted store to keep your passwords or
tokens secure.

In addition, you can use the store credential manager which stores in a file
in your home directory, or the cache credential manager, which does not
permanently store your credentials, but does prevent you from being prompted for
them for a certain period of time.

You can also just enter your password when prompted. While it is possible to
place the password (which must be percent-encoded) in the URL, this is not
particularly secure and can lead to accidental exposure of credentials, so it is
not recommended.

How do I read a password or token from an environment variable?

The credential.helper configuration option can also take an arbitrary
shell command that produces the credential protocol on standard output.
This is useful when passing credentials into a container, for example.

Such a shell command can be specified by starting the option value with an
exclamation point. If your password or token were stored in the GIT_TOKEN,
you could run the following command to set your credential helper:

$ git config credential.helper 
	'!f() { echo username=author; echo "password=$GIT_TOKEN"; };f'
How do I change the password or token I’ve saved in my credential manager?

Usually, if the password or token is invalid, Git will erase it and
prompt for a new one. However, there are times when this doesn’t always
happen. To change the password or token, you can erase the existing
credentials and then Git will prompt for new ones. To erase
credentials, use a syntax like the following (substituting your username
and the hostname):

$ echo url=https://author@git.example.org | git credential reject
How do I use multiple accounts with the same hosting provider using HTTP?

Usually the easiest way to distinguish between these accounts is to use
the username in the URL. For example, if you have the accounts author
and committer on git.example.org, you can use the URLs
https://author@git.example.org/org1/project1.git and
https://committer@git.example.org/org2/project2.git. This way, when you
use a credential helper, it will automatically try to look up the
correct credentials for your account. If you already have a remote set
up, you can change the URL with something like git remote set-url
origin https://author@git.example.org/org1/project1.git
(see
git-remote[1] for details).

How do I use multiple accounts with the same hosting provider using SSH?

With most hosting providers that support SSH, a single key pair uniquely
identifies a user. Therefore, to use multiple accounts, it’s necessary
to create a key pair for each account. If you’re using a reasonably
modern OpenSSH version, you can create a new key pair with something
like ssh-keygen -t ed25519 -f ~/.ssh/id_committer. You can then
register the public key (in this case, ~/.ssh/id_committer.pub; note
the .pub) with the hosting provider.

Most hosting providers use a single SSH account for pushing; that is, all users
push to the git account (e.g., git@git.example.org). If that’s the case for
your provider, you can set up multiple aliases in SSH to make it clear which key
pair to use. For example, you could write something like the following in
~/.ssh/config, substituting the proper private key file:

# This is the account for author on git.example.org.
Host example_author
	HostName git.example.org
	User git
	# This is the key pair registered for author with git.example.org.
	IdentityFile ~/.ssh/id_author
	IdentitiesOnly yes
# This is the account for committer on git.example.org.
Host example_committer
	HostName git.example.org
	User git
	# This is the key pair registered for committer with git.example.org.
	IdentityFile ~/.ssh/id_committer
	IdentitiesOnly yes

Then, you can adjust your push URL to use git@example_author or
git@example_committer instead of git@example.org (e.g., git remote set-url
git@example_author:org1/project1.git
).

Common Issues

I’ve made a mistake in the last commit. How do I change it?

You can make the appropriate change to your working tree, run git add
<file>
or git rm <file>, as appropriate, to stage it, and then git
commit --amend
. Your change will be included in the commit, and you’ll
be prompted to edit the commit message again; if you wish to use the
original message verbatim, you can use the --no-edit option to git
commit
in addition, or just save and quit when your editor opens.

I’ve made a change with a bug and it’s been included in the main branch. How should I undo it?

The usual way to deal with this is to use git revert. This preserves
the history that the original change was made and was a valuable
contribution, but also introduces a new commit that undoes those changes
because the original had a problem. The commit message of the revert
indicates the commit which was reverted and is usually edited to include
an explanation as to why the revert was made.

How do I ignore changes to a tracked file?

Git doesn’t provide a way to do this. The reason is that if Git needs
to overwrite this file, such as during a checkout, it doesn’t know
whether the changes to the file are precious and should be kept, or
whether they are irrelevant and can safely be destroyed. Therefore, it
has to take the safe route and always preserve them.

It’s tempting to try to use certain features of git update-index, namely the
assume-unchanged and skip-worktree bits, but these don’t work properly for this
purpose and shouldn’t be used this way.

If your goal is to modify a configuration file, it can often be helpful to have
a file checked into the repository which is a template or set of defaults which
can then be copied alongside and modified as appropriate. This second, modified
file is usually ignored to prevent accidentally committing it.

I asked Git to ignore various files, yet they are still tracked

A gitignore file ensures that certain file(s) which are not
tracked by Git remain untracked. However, sometimes particular
file(s) may have been tracked before adding them into the
.gitignore, hence they still remain tracked. To untrack and
ignore files/patterns, use git rm --cached <file/pattern>
and add a pattern to .gitignore that matches the <file>.
See gitignore[5] for details.

How do I know if I want to do a fetch or a pull?

A fetch stores a copy of the latest changes from the remote
repository, without modifying the working tree or current branch.
You can then at your leisure inspect, merge, rebase on top of, or
ignore the upstream changes. A pull consists of a fetch followed
immediately by either a merge or rebase. See git-pull[1].

Merging and Rebasing

What kinds of problems can occur when merging long-lived branches with squash merges?

In general, there are a variety of problems that can occur when using squash
merges to merge two branches multiple times. These can include seeing extra
commits in git log output, with a GUI, or when using the ... notation to
express a range, as well as the possibility of needing to re-resolve conflicts
again and again.

When Git does a normal merge between two branches, it considers exactly three
points: the two branches and a third commit, called the merge base, which is
usually the common ancestor of the commits. The result of the merge is the sum
of the changes between the merge base and each head. When you merge two
branches with a regular merge commit, this results in a new commit which will
end up as a merge base when they’re merged again, because there is now a new
common ancestor. Git doesn’t have to consider changes that occurred before the
merge base, so you don’t have to re-resolve any conflicts you resolved before.

When you perform a squash merge, a merge commit isn’t created; instead, the
changes from one side are applied as a regular commit to the other side. This
means that the merge base for these branches won’t have changed, and so when Git
goes to perform its next merge, it considers all of the changes that it
considered the last time plus the new changes. That means any conflicts may
need to be re-resolved. Similarly, anything using the ... notation in git
diff
, git log, or a GUI will result in showing all of the changes since the
original merge base.

As a consequence, if you want to merge two long-lived branches repeatedly, it’s
best to always use a regular merge commit.

If I make a change on two branches but revert it on one, why does the merge of those branches include the change?

By default, when Git does a merge, it uses a strategy called the ort
strategy, which does a fancy three-way merge. In such a case, when Git
performs the merge, it considers exactly three points: the two heads and a
third point, called the merge base, which is usually the common ancestor of
those commits. Git does not consider the history or the individual commits
that have happened on those branches at all.

As a result, if both sides have a change and one side has reverted that change,
the result is to include the change. This is because the code has changed on
one side and there is no net change on the other, and in this scenario, Git
adopts the change.

If this is a problem for you, you can do a rebase instead, rebasing the branch
with the revert onto the other branch. A rebase in this scenario will revert
the change, because a rebase applies each individual commit, including the
revert. Note that rebases rewrite history, so you should avoid rebasing
published branches unless you’re sure you’re comfortable with that. See the
NOTES section in git-rebase[1] for more details.

Hooks

How do I use hooks to prevent users from making certain changes?

The only safe place to make these changes is on the remote repository
(i.e., the Git server), usually in the pre-receive hook or in a
continuous integration (CI) system. These are the locations in which
policy can be enforced effectively.

It’s common to try to use pre-commit hooks (or, for commit messages,
commit-msg hooks) to check these things, which is great if you’re working as a
solo developer and want the tooling to help you. However, using hooks on a
developer machine is not effective as a policy control because a user can bypass
these hooks with --no-verify without being noticed (among various other ways).
Git assumes that the user is in control of their local repositories and doesn’t
try to prevent this or tattle on the user.

In addition, some advanced users find pre-commit hooks to be an impediment to
workflows that use temporary commits to stage work in progress or that create
fixup commits, so it’s better to push these kinds of checks to the server
anyway.

Cross-Platform Issues

I’m on Windows and my text files are detected as binary.

Git works best when you store text files as UTF-8. Many programs on
Windows support UTF-8, but some do not and only use the little-endian
UTF-16 format, which Git detects as binary. If you can’t use UTF-8 with
your programs, you can specify a working tree encoding that indicates
which encoding your files should be checked out with, while still
storing these files as UTF-8 in the repository. This allows tools like
git-diff[1] to work as expected, while still allowing your tools
to work.

To do so, you can specify a gitattributes[5] pattern with the
working-tree-encoding attribute. For example, the following pattern sets all
C files to use UTF-16LE-BOM, which is a common encoding on Windows:

*.c	working-tree-encoding=UTF-16LE-BOM

You will need to run git add --renormalize to have this take effect. Note
that if you are making these changes on a project that is used across platforms,
you’ll probably want to make it in a per-user configuration file or in the one
in $GIT_DIR/info/attributes, since making it in a .gitattributes file in the
repository will apply to all users of the repository.

See the following entry for information about normalizing line endings as well,
and see gitattributes[5] for more information about attribute files.

I’m on Windows and git diff shows my files as having a ^M at the end.

By default, Git expects files to be stored with Unix line endings. As such,
the carriage return (^M) that is part of a Windows line ending is shown
because it is considered to be trailing whitespace. Git defaults to showing
trailing whitespace only on new lines, not existing ones.

You can store the files in the repository with Unix line endings and convert
them automatically to your platform’s line endings. To do that, set the
configuration option core.eol to native and see the following entry for
information about how to configure files as text or binary.

You can also control this behavior with the core.whitespace setting if you
don’t wish to remove the carriage returns from your line endings.

Why do I have a file that’s always modified?

Internally, Git always stores file names as sequences of bytes and doesn’t
perform any encoding or case folding. However, Windows and macOS by default
both perform case folding on file names. As a result, it’s possible to end up
with multiple files or directories whose names differ only in case. Git can
handle this just fine, but the file system can store only one of these files,
so when Git reads the other file to see its contents, it looks modified.

It’s best to remove one of the files such that you only have one file. You can
do this with commands like the following (assuming two files AFile.txt and
afile.txt) on an otherwise clean working tree:

$ git rm --cached AFile.txt
$ git commit -m 'Remove files conflicting in case'
$ git checkout .

This avoids touching the disk, but removes the additional file. Your project
may prefer to adopt a naming convention, such as all-lowercase names, to avoid
this problem from occurring again; such a convention can be checked using a
pre-receive hook or as part of a continuous integration (CI) system.

It is also possible for perpetually modified files to occur on any platform if a
smudge or clean filter is in use on your system but a file was previously
committed without running the smudge or clean filter. To fix this, run the
following on an otherwise clean working tree:

$ git add --renormalize .
What’s the recommended way to store files in Git?

While Git can store and handle any file of any type, there are some
settings that work better than others. In general, we recommend that
text files be stored in UTF-8 without a byte-order mark (BOM) with LF
(Unix-style) endings. We also recommend the use of UTF-8 (again,
without BOM) in commit messages. These are the settings that work best
across platforms and with tools such as git diff and git merge.

Additionally, if you have a choice between storage formats that are text based
or non-text based, we recommend storing files in the text format and, if
necessary, transforming them into the other format. For example, a text-based
SQL dump with one record per line will work much better for diffing and merging
than an actual database file. Similarly, text-based formats such as Markdown
and AsciiDoc will work better than binary formats such as Microsoft Word and
PDF.

Similarly, storing binary dependencies (e.g., shared libraries or JAR files) or
build products in the repository is generally not recommended. Dependencies and
build products are best stored on an artifact or package server with only
references, URLs, and hashes stored in the repository.

We also recommend setting a gitattributes[5] file to explicitly mark
which files are text and which are binary. If you want Git to guess, you can
set the attribute text=auto. For example, the following might be appropriate
in some projects:

# By default, guess.
*	text=auto
# Mark all C files as text.
*.c	text
# Mark all JPEG files as binary.
*.jpg	binary

These settings help tools pick the right format for output such as patches and
result in files being checked out in the appropriate line ending for the
platform.

Git is awesome and I love it. Plain and simple. It works. Yet, there are occasions when things within Git break. And then you have to go googlebing for the solution.

I’m just back from a 2-week holiday and, as expected, my Windows credentials had expired so I changed them. Then I tried to do a git pull and I got this nice error message:

$ git pull
fatal: Authentication failed for `repo url/`

Apparently, updating my domain credentials also broke my Git credentials. At first, I thought there was an issue with my credential.helper. So I unset it and set it again. No joy. Then my good friend David Rankin (@rankida) came to the rescue. (We started work on the same day, so his account creds expired while I was off).

To update your credentials, go to Control Panel -> Credential Manager -> Generic Credentials. Find the credentials related to your git account and edit them to use the updated passwords as per the image below:

I hope this helps with your Git issues. Special thanks to David who had to do the ‘hard work’.

P.S Follow me on Twitter @christosmatskas for more up-to-date news, articles and tips.

P.S. Make sure you follow me on Twitter @christosmatskas for more up-to-date news, articles and tips.

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…

29 Answers

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

In Windows 10 with Git

Remove/update related Credentials stored in Windows Credentials in >>Control PanelAll Control Panel ItemsCredential Manager

enter image description here

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.

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

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.

In windows 10 at mentioned above by @Imran Javed you can find Generic Credentials at :

Control PanelAll Control Panel ItemsCredential Manager —> Windows Credentials

for your git server and then you can update password by clicking edit button.

enter image description here

For Mac

If you have multiple remote repositories (Github, Bitbucket, Job, etc.)

1) run in the project directory

git config --unset user.password

2) run remote git command (ie. git push or git pull)

Git will prompt you to reenter your user.name and user.password for this repository

Or you can do it globally if you have only one remote repository

git config --global --unset user.password

running git config --global --unset user.password followed by any git command would prompt you to enter username and password.

git config --global --unset user.password
git push (will prompt you for the password)
git status (will not prompt for password again)

If you are MAC user then you can open KeyChain Access Application from finder and then look for your account listed there. Just click on it and update your password.
Now give a try and things will fall in place.

link for reference: Updating your credentials via Keychain Access

Worked for me. :)

In my Windows machine, I tried the solution of @nzrytmn i.e.,
Control Panel>Search Credentials>Select «ManageCredentials»>modified new credentials under git option category corresponding to my username.
And then,

Deleted current password:

git config --global --unset user.password

Added new password:

git config --global --add user.password "new_password"

And It worked for me.

I was pushing into the repository for the first time. So there was no HEAD defined.

The easiest way would be to:

git push -u origin master

It will then prompt for the password, and once you enter that it will be saved automatically, and you will be able to push.

If you are using github and have enabled 2 factor authentication, you need to enter a Personal access token instead of your password

First reset your password:

git config --global --unset user.password

Then, log to your github account, on the right hand corner, click on Settings, then Developer Settings. Generate a Personal access token. Copy it.

git push

The terminal will prompt you for your username: enter your email address.

At the password prompt, enter the personal access token instead.

If your credentials are stored in the credential helper, the portable way to remove a password persisted for a specific host is to call git credential reject:

$ git credential reject
protocol=https
host=bitbucket.org
⏎

or

$ git credential reject
url=https://bitbucket.org
⏎

After that, to enter your new password, type git fetch.

There is such a confusion on this question, as there is way too much complexity in this question. First MacOS vs. Win10. Then the different auth mechanisms.

I will start a consolidated answer here and probably need some help, if I do not get help, I will keep working on the answer until it is complete, but that will take time.

Windows 10: |

|-- Run this command. You will be prompted on next push/pull to enter username and password:
|      git config --global credential.helper wincred (Thanks to @Andrew Pye)

`
MacOS:

|
|-- Using git config to store username and password:
|  git config --global --add user.password
|
|---- first time entry
|  git config --global --add user.password <new_pass>
|
|---- password update
|  git config --global --unset user.password
|  git config --global --add user.password <new_pass>
|
|-- Using keychain:
|  git config --global credential.helper osxkeychain
|
|---- first time entry
|  Terminal will ask you for the username and password. Just enter it, it will be 
|  stored in keychain from then on.
|
|---- password update
|  Open keychain, delete the entry for the repository you are trying to use. 
|  (git remote -v will show you)
|  On next use of git push or something that needs permissions, git will ask for 
|  the credentials, as it can not find them in the keychain anymore.
`

do these steps in Terminal:

  1. Delete current password saved in your Mac

    git config --global --unset user.password
    
  2. Add your new password by using this command, replace with your new password:

    git config --global --add user.password <new_pass>
    

you can change password through command line in 2 places, following would edit credentials to connect the repo

git config --edit 

The credentials also can be changed at global using global parameter like below

 git config --global --add user.password "XXXX"

or set the credentials helper with

git config --global credential.helper wincred

but if you have repo level credentials set the use the first command

git config --edit

I was able to change my git password by going to Credential Manager in Windows and deleting all the git entries under Windows Credentials 🡒 Generic Credentials.

When doing a git pull or git push, windows will ask for the new user/password itself.

I would try to delete my account in Keychain Access and then run git clone again. Git will ask me for a new password.

None of the other answers worked for me on MacOS Big Sur 11.3.1

I had Two-Factor Authentication enabled on Github, this makes is so you will fail when entering your username and password even when they are correct.

Here is what I had to do:

`git config --global --unset user.password`

Then run your git command (ex. git push) and enter your username.
For the password you need to generate a Personal Access Token.

Go to https://github.com/settings/profile select the Developer Settings on the right. Select Personal Access Token Generate new token. Copy the generated token and use it as the password in terminal.

Tried everything but nothing worked. Then the following did work.

  1. Before any of the above steps, lock and unlock the keychain again coz sometimes it sorta gets stuck.
  2. Install the GitHub Desktop — it helps.

on mac BigSur 11.2.3
I updated the credentials in the key chain then I ran the command below.

git credential-osxkeychain erase
host=github.com
protocol=https

I had to do this because no other solution in this thread worked for me after changing to token auth for github. github kept stating repository not found.
If this does not work try to combine this with the other commands for mac in this thread.

For those who are looking for how to reset access to the repository. By the example of GitHub. You can change your GitHub profile password and revoke all «Personal access tokens» in «Settings -> Developer settings» of your profile. Also you can optionally wipe all your SSH/PGP keys and OAuth/GitHub apps to be sure that access to the repository is completely blocked. Thus, all the credential managers, on any system will fail at authorisation and prompt you to enter the new credentials.

Following steps can resolve the issue …..

  1. Go to the folder ~/Library/Application Support/SourceTree
  2. Delete the file {Username}@STAuth-bitbucket.org
  3. Restart Sourcetree
  4. Try to fetch, password filed appear, give your new password
  5. Also can run «git fetch» command in terminal and need to type password
  6. Done

my password was good in github desktop preferences but wrong in the .git/config file

for me the only working solution was to manually edit the file:
.git/config

that contains this line:
url = https://user:[email protected]/user/repo.git

change password to the GOOD password because it was an older one for me

None of the command line options from within terminal worked for me. Ultimately, I just opened up keychain manually, searched for ‘git’ under ‘All Items’, found an entry there and deleted it. That did it! Next time I tried a git pull from the terminal and it prompted me for new creds.

In this article, they explain it in a very easy way but basically, we just need to execute a git remote set-url origin "https://<yourUserName>@bitbucket.org/<yourRepo>" and next time you do a git pull or a git push you will have to put your password.

For MAC users, using git GUI (Works for Sourcetree, may work for others as well). Would like to add a small remark to Derek’s answer (https://stackoverflow.com/a/45703718/7138492). The original suggestion:

$ git config --global --unset user.password

should be followed by a push/pull/fetch BUT it might not work when done from the GUI. The %100 working case would be to do the very first consecutive prompt-triggering git command from console. Here is an example:

  1. Locate to your git repository root directory
  2. Type in $ git config --unset user.password
  3. Proceed with a git commend of your choice in terminal e.g.: $ git push

Then it will ask you to provide the new passoword.

Just do a git pull of any of your repository and you will be prompted to enter your new password.

Git is an open-source version control system. Git is software that helps to track updates in any folder. It is a DevOps resource used mostly for source code planning. It’s typically used to promote collaboration between coders who are relying on source code together during software development. Speed, the integrity of data, including support for dispersed, non-linear workflows are among the aims.

A terminal Git environment is handled by Git Bash (Bash, an acronym for Bourne Again Shell).  Git Bash replicates a bash terminal on Windows. It allows you to use all git tools or most other typical Unix commands from the command line. If you’re used to Linux and want to preserve your routines, this is a great alternative.

Git is usually bundled as one of the elevated GUI applications in Windows settings. Bash is a popular Linux and Mac OS default shell. On a Windows operating system, Git Bash is a package that installs Bash, some standard bash utilities, and Git.  The fundamental version control system primitives may be abstracted and hidden by Git’s GUI. Git Bash is a Microsoft Windows software that functions as an abstraction shell for the Git command-line experience. A shell is a console application that allows you to interact with your operating system by command prompt.

Now let us discuss how to set Git Username and Password in Git Bash

Step 1: After the successful installation of Git on your system, you have to right-click wherever you want to open the Git tab. Click on the Git Bash Here icon. Now here we will see the location of where the program is opened when the window opens.

Git Bash opened on Desktop.

Step 2: In the Git Bash window, type the below command and press enter. This will configure your Username in Git Bash.

$ git config --global user.name "GeeksforGeeks"

Step 3: After that, you will have to configure your email. For that, type

$git config --global user.email "GFGexample@gmail.orgg"

Step 4: To set your password, type the below command as depicted:

$git config --global user.password "1234321"

Step 5: To save the credentials forever, type the below command as depicted:

$ git config --global credential.helper store

This is how you set git username and password in git bash.

To check the inputs, type the below command as depicted:

git config --list --show-origin

Содержание

  1. Как обновить пароль для Git?
  2. 10 ответов
  3. Updating your GitHub access credentials
  4. Help us make these docs great!
  5. Configuring user and password with Git Bash
  6. 11 Answers 11
  7. Как мне обновить пароль для Git?
  8. 12 Answers 12

Как обновить пароль для Git?

Я использую BitBucket с Xcode и Git для контроля версий, и недавно я изменил все свои пароли ( спасибо Adobe!).

неудивительно, что я больше не могу нажимать свои локальные коммиты в свой репозиторий на BitBucket ( Authentication failed for ‘https://______.git’ ), но я забываю, как обновить кэшированный пароль на моем iMac. Почему-то я не смог найти его в Google или Stack Overflow, хотя мне кажется, что это должно быть довольно просто.

10 ответов

чтобы исправить это, вы можете использовать

затем вам снова будет предложено ввести пароль.

для Windows это та же команда с другим аргументом:

ни один из других ответов не работал для меня на MacOS Sierra 10.12.4

вот что я должен был сделать:

затем запустите команду git (ex. git push) и повторно введите свое имя пользователя и пароль.

У меня была та же проблема, и принятый ответ не помог мне, потому что пароль не был сохранен в связке ключей. Я набрал:

затем консоль попросила у меня новый пароль.

единственный способ изменить пароль git-это перейти в Диспетчер учетных данных в Windows (ключ Windows + тип «учетные данные») и отредактировать запись git под универсальными учетными данными Windows. Примечание: не указан в алфавитном порядке

в Windows 10 с Git

удалить / обновить связанные учетные данные, хранящиеся в учетных данных Windows в > > Панель управлениявсе элементы панели управленияДиспетчер учетных данных

cbacbe97a13413df0dacadaa46c1002f

я толкаю в хранилище в первый раз. Так нет HEAD определены.

самым простым способом было бы:

затем он запросит пароль, и как только вы введете его, он будет сохранен автоматически, и вы сможете нажать.

Если вы пользователь MAC, то вы можете открыть приложение KeyChain Access из finder, а затем искать свою учетную запись, указанную там. Просто нажмите на него и обновите пароль. Теперь попробуйте, и все встанет на свои места.

в windows 10 в упомянутом выше @Imran Javed вы можете найти общие учетные данные по адресу:

для вашего сервера git, а затем вы можете обновить пароль, нажав кнопку Изменить.

8b9e08e7e8baf27dd4659ebe11465218

пробовал все, но ничего не получалось. Затем сработало следующее.

Я бы попытался удалить свою учетную запись в Keychain Access, а затем запустить git clone снова. Git попросит у меня новый пароль.

Источник

Updating your GitHub access credentials

GitHub credentials include not only your password, but also the access tokens, SSH keys, and application API tokens you use to communicate with GitHub. Should you have the need, you can reset all of these access credentials yourself.

Requesting a new password

To avoid losing your password in the future, we suggest using a secure password manager, like LastPass or 1Password.

Changing an existing password

When you type a password to sign in, create an account, or change your password, GitHub will check if the password you entered is considered weak according to datasets like HaveIBeenPwned. The password may be identified as weak even if you have never used that password before.

GitHub only inspects the password at the time you type it, and never stores the password you entered in plaintext. For more information, see HaveIBeenPwned.

For greater security, enable two-factor authentication in addition to changing your password. See About two-factor authentication for more details.

Updating your access tokens

See «Reviewing your authorized integrations» for instructions on reviewing and deleting access tokens. To generate new access tokens, see «Creating a personal access token.»

Updating your SSH keys

See «Reviewing your SSH keys» for instructions on reviewing and deleting SSH keys. To generate and add new SSH keys, see «Generating an SSH key.»

Resetting API tokens

If you have any applications registered with GitHub, you’ll want to reset their OAuth tokens. For more information, see the «Reset an authorization» endpoint.

Preventing unauthorized access

For more tips on securing your account and preventing unauthorized access, see «Preventing unauthorized access.»

Help us make these docs great!

All GitHub docs are open source. See something that’s wrong or unclear? Submit a pull request.

Источник

Configuring user and password with Git Bash

I am using Git Bash on Windows 7. We are using GitHub as our repository origin.

Every time I push or pull I have to provide user and password credentials. I know that my SSH keys are set up correctly, otherwise I would not be able to access the repository. (That is, once I enter my credentials the push/pull works correctly.)

But nonetheless I am being asked for credentials each and every time I push/pull.

RIZKi

11 Answers 11

You can change the URL with: [1]

[1] This portion incorporates the answer to this question.

From Git Bash I prefer to run the command:

RIZKi

For those who are using access token and a Windows environment, there is a simple way to do it:

Start menu → Credential ManagerWindows Credentials → find the line (Git: https://whatever/your-repository/url) → edit, user name is «github_username» and password is your access token.

photo

photo

If you are a Mac user and have keychain enabled, you to need to remove the authorization information that is stored in the keychain:

Then you should change your username and email from the terminal using git config :

Now if you try to push to the repository you will be asked for a username and password. Enter the login credentials you are trying to switch to. This problem normally pops up if you signed into GitHub on a browser using a different username and password or previously switched accounts on your terminal.

RIZKi

With git bash for Windows, the following combination of the other answers worked for me (repository checked out using the GitHub client i.e. https, not ssh):

I wrote an answer in this other answer: How to change git account in Git bash?

Still, I am sharing it here as well.

Change username and email global

Change username and email for current repo

nd7k2

Try ssh-agent for installing the SSH key for use with Git. It should auto login after use of a passphrase.

RIZKi

If the git bash is not working properly due to recently changed password.

You could open the Git GUI, and clone from there. It will ask for password, once entered, you can close the GIT GUI window.

Now the git bash will work perfectly.

So, From then while you pull / push the code to the repository it will not ask for password.

GnuPG can be used as cross-platform password manager, including GIT HTTPS credetials. Just use your GPG key-pair to encrypt/decrypt passwords(tokens. ). To encrypt token(password) run:

type the token (or copy-paste it) then press Ctrl+D for ending input, or use file name with this token. Then make custom git credential helper: BASH file with name git-credential-[HELPER_LAST_NAME] (without SH extension):

GnuPG can be used as password manager in Maven projects instead of Maven’s password-encryption method. And so on.

Источник

Как мне обновить пароль для Git?

Я использую BitBucket с Xcode и Git для контроля версий, и недавно я изменил все свои пароли ( спасибо Adobe! ).

Чтобы исправить это на macOS, вы можете использовать

При следующем действии Git появится запрос имени пользователя и пароля (pull, clone, push и т. Д.).

Для Windows это та же команда с другим аргументом:

Ни один из других ответов не работал для меня на MacOS Sierra 10.12.4

Вот что я должен был сделать:

Затем выполните команду git (например, git push) и повторно введите имя пользователя и пароль.

В Windows 10 с Git

Удалить / обновить связанные учетные данные, хранящиеся в учетных данных Windows в >> Панель управления Все элементы панели управления Диспетчер учетных данных

UlNge

У меня была та же проблема, и принятый ответ не помог мне, потому что пароль не был сохранен в цепочке для ключей. Я набрал:

Затем консоль попросила у меня новый пароль.

В Windows 10, указанной выше @Imran Javed, вы можете найти общие учетные данные по адресу:

для вашего сервера git, а затем вы можете обновить пароль, нажав кнопку редактирования.

uMjON

На моей машине с Windows я попробовал решение @nzrytmn, т. Е. Панель управления> Поиск учетных данных> Выберите «ManageCredentials»> изменил новые учетные данные в категории параметров git, соответствующих моему имени пользователя. А потом,

Удален текущий пароль:

Добавлен новый пароль:

И это сработало для меня.

Если вы пользователь MAC, вы можете открыть KeyChain Access Application из поиска, а затем найти свою учетную запись, указанную там. Просто нажмите на него и обновите свой пароль. Теперь попробуйте, и все станет на свои места.

Я впервые запихивал в хранилище. Так что не было HEAD определено.

Самый простой способ:

Затем вам будет предложено ввести пароль, и как только вы введете его, он будет автоматически сохранен, и вы сможете нажать.

выполните эти шаги в терминале:

Удалить текущий пароль, сохраненный на вашем Mac

Добавьте новый пароль с помощью этой команды, замените его новым паролем:

Если ваши учетные данные хранятся в помощнике по учетным данным, переносимый способ удаления пароля для определенного хоста заключается в следующем git credential reject :

В этом вопросе такая путаница, поскольку в этом вопросе слишком много сложности. Первый MacOS против Win10. Тогда разные механизмы аутентификации.

Здесь я начну сводный ответ и, возможно, мне понадобится некоторая помощь. Если я не получу помощь, я продолжу работать над ответом, пока он не будет завершен, но это займет время.

Вы можете сменить пароль через командную строку в 2 местах, после чего измените учетные данные для подключения к репо

Учетные данные также могут быть изменены на глобальном уровне с помощью глобального параметра, как показано ниже

или установите помощник учетных данных с помощью

но если у вас есть учетные данные уровня репо, установите первую команду

Если у вас есть несколько удаленных репозиториев (Github, Bitbucket, Job и т. Д.)

1) запустить в каталоге проекта

2) запустить удаленную команду git (т.е. git push или git pull)

Git предложит вам повторно ввести ваши user.name и user.password для этого хранилища

Или вы можете сделать это глобально, если у вас есть только один удаленный репозиторий

Если вы используете github и включили двухфакторную аутентификацию, вам нужно ввести токен личного доступа вместо пароля

Сначала сбросьте свой пароль:

Затем войдите в свою учетную запись github, в правом углу нажмите «Настройки», затем «Настройки разработчика». Создайте токен личного доступа. Скопируйте это.

Терминал запросит у вас имя пользователя: введите адрес электронной почты.

По запросу пароля введите токен личного доступа.

Источник

I’m currently using GitHub over HTTPS and have the latest version of Git installed (1.9.0) along with the Git credential helper on Windows 7.

On setting up my environment, I told git-credentials to permanently remember my username and password.

I’ve recently updated my GitHub password via the website and I’m now no longer able to push/pull/fetch, etc.

How I would go about updating my password on git-credentials helper on Windows 7?

RIZKi

12 Answers 12

None of these answers ended up working for my Git credential issue. Here is what did work if anyone needs it (I’m using Git 1.9 on Windows 8.1).

To update your credentials, go to Control PanelCredential ManagerGeneric Credentials. Find the credentials related to your Git account and edit them to use the updated password.

Note that to use the Windows Credential Manager for Git you need to configure the credential helper like so:

If you have multiple GitHub accounts that you use for different repositories, then you should configure credentials to use the full repository path (rather than just the domain, which is the default):

RIZKi

iwFwf

On my first attempt to Git fetch after my password change, I was told that my username/password combination was invalid. This was correct as git-credential helper had cached my old values.

However, I attempted another git fetch after restarting my terminal/command-prompt and this time the credential helper prompted me to enter in my GitHub username and password.

I suspect the initial failed Git fetch request in combination with restarting my terminal/command-prompt resolved this for me.

I hope this answer helps anybody else in a similar position in the future!

RIZKi

If you are a Windows user, you may either remove or update your credentials in Credential Manager.

In Windows 10, go to the below path:

Control PanelAll Control Panel ItemsCredential Manager

Or search for «credential manager» in your «Search Windows» section in the Start menu.

Then from the Credential Manager, select «Windows Credentials».

Credential Manager will show many items including your outlook and GitHub repository under «Generic credentials»

You click on the drop down arrow on the right side of your Git: and it will show options to edit and remove. If you remove, the credential popup will come next time when you fetch or pull. Or you can directly edit the credentials there.

RIZKi

Solution using command line for Windows, Linux, and MacOS

If you have updated your GitHub password on the GitHub server, in the first attempt of the git fetch/pull/push command it generates the authentication failed message.

Execute the same git fetch/pull/push command a second time and it prompts for credentials (username and password). Enter the username and the new updated password of the GitHub server and login will be successful.

Even I had this problem, and I performed the above steps and done!!

RIZKi

Now, it won’t prompt for the password for multiple times in Git.

6q1nz

It seems to me that the answers here are outdated. For me using Git v2.15.0 this did the job:

And then to set the new username & password:

FWIW, I stumbled over this very same problem (and my boss too, so it got more intense).

In Microsoft’s Git Credential Manager this is a known issue that may be fixed as soon as early 2019 (so don’t hold your breath).

Источник

To connect to a Git repository with authentication over HTTP(S), every time it needs to set a username and password.

You can configure Git to remember a username and password by storing them in a remote URL or by using Git credential helper.

In this article i am showing how to clone Git repository by setting a username and password on the command line, how to save a username and password in Git credentials storage and how to configure different usernames and passwords for different repositories on the same Git server.

Cool Tip: Show Git branch name in the command prompt! Read more →

Warning: Your Git credentials will be saved in a plaintext format in the files .git/config or ~/.git-credentials, depending on the method you choose.

Set Username and Password in Remote URL

To save credentials you can clone Git repository by setting a username and password on the command line:

$ git clone https://<USERNAME>:<PASSWORD>@github.com/path/to/repo.git

The username and password will be stored in .git/config file as a part of the remote repository URL.

If you have already cloned a repository without setting username and password on the command line, you can always update the remote URL by running the following command:

$ git remote set-url origin https://<USERNAME>:<PASSWORD>@github.com/path/to/repo.git

Save Username and Password in Git Credentials Storage

Run the following command to enable credentials storage in your Git repository:

$ git config credential.helper store

To enable credentials storage globally, run:

$ git config --global credential.helper store

When credentials storage is enabled, the first time you pull or push from the remote Git repository, you will be asked for a username and password, and they will be saved in ~/.git-credentials file.

During the next communications with the remote Git repository you won’t have to provide the username and password.

Each credential in ~/.git-credentials file is stored on its own line as a URL like:

https://<USERNAME>:<PASSWORD>@github.com

Config Username and Password for Different Repositories

Sometimes you may need to use different accounts on the same Git server, for example your company’s corporate account on github.com and your private one.

To be able to configure usernames and passwords for different Git repositories on the same Git server you can enable the useHttpPath option.

By default, Git does not consider the “path” component of an http URL to be worth matching via external helpers. This means that a credential stored for https://example.com/foo.git will also be used for https://example.com/bar.git. If you do want to distinguish these cases, set useHttpPath option to true (source)

Run the following commands to configure Git credentials storage and separate credentials for different repositories on github.com:

$ git config --global credential.helper store
$ git config --global credential.github.com.useHttpPath true

The usernames and passwords for different GitHub repositories will be stored in ~/.git-credentials file separately on their own lines:

https://<USERNAME>:<PASSWORD>@github.com/path/to/repo1.git
https://<USERNAME>:<PASSWORD>@github.com/path/to/repo2.git

Cool Tip: Create a new Git branch and checkout in one command! Read More →

Adding a remote repository

To add a new remote, use the git remote add command on the terminal, in the directory your repository is stored at.

The git remote add command takes two arguments:

  • A remote name, for example, origin
  • A remote URL, for example, https://github.com/user/repo.git

For example:

$ git remote add origin https://github.com/USER/REPO.git
# Set a new remote

$ git remote -v
# Verify new remote
> origin  https://github.com/USER/REPO.git (fetch)
> origin  https://github.com/USER/REPO.git (push)

For more information on which URL to use, see «About remote repositories.»

Troubleshooting: Remote origin already exists

This error means you’ve tried to add a remote with a name that already exists in your local repository.

$ git remote add origin https://github.com/octocat/Spoon-Knife.git
> fatal: remote origin already exists.

To fix this, you can:

  • Use a different name for the new remote.
  • Rename the existing remote repository before you add the new remote. For more information, see «Renaming a remote repository» below.
  • Delete the existing remote repository before you add the new remote. For more information, see «Removing a remote repository» below.

Changing a remote repository’s URL

The git remote set-url command changes an existing remote repository URL.

The git remote set-url command takes two arguments:

  • An existing remote name. For example, origin or upstream are two common choices.
  • A new URL for the remote. For example:
    • If you’re updating to use HTTPS, your URL might look like:
      https://github.com/USERNAME/REPOSITORY.git
    • If you’re updating to use SSH, your URL might look like:
      git@github.com:USERNAME/REPOSITORY.git

Switching remote URLs from SSH to HTTPS

  1. Open TerminalTerminalGit Bash.
  2. Change the current working directory to your local project.
  3. List your existing remotes in order to get the name of the remote you want to change.
    $ git remote -v
    > origin  git@github.com:USERNAME/REPOSITORY.git (fetch)
    > origin  git@github.com:USERNAME/REPOSITORY.git (push)
  4. Change your remote’s URL from SSH to HTTPS with the git remote set-url command.
    $ git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
  5. Verify that the remote URL has changed.
    $ git remote -v
    # Verify new remote URL
    > origin  https://github.com/USERNAME/REPOSITORY.git (fetch)
    > origin  https://github.com/USERNAME/REPOSITORY.git (push)

The next time you git fetch, git pull, or git push to the remote repository, you’ll be asked for your GitHub username and password. When Git prompts you for your password, enter your personal access token. Alternatively, you can use a credential helper like Git Credential Manager. Password-based authentication for Git has been removed in favor of more secure authentication methods. For more information, see «Creating a personal access token.»

You can use a credential helper so Git will remember your GitHub username and personal access token every time it talks to GitHub.

Switching remote URLs from HTTPS to SSH

  1. Open TerminalTerminalGit Bash.
  2. Change the current working directory to your local project.
  3. List your existing remotes in order to get the name of the remote you want to change.
    $ git remote -v
    > origin  https://github.com/USERNAME/REPOSITORY.git (fetch)
    > origin  https://github.com/USERNAME/REPOSITORY.git (push)
  4. Change your remote’s URL from HTTPS to SSH with the git remote set-url command.
    $ git remote set-url origin git@github.com:USERNAME/REPOSITORY.git
  5. Verify that the remote URL has changed.
    $ git remote -v
    # Verify new remote URL
    > origin  git@github.com: USERNAME/REPOSITORY.git (fetch)
    > origin  git@github.com: USERNAME/REPOSITORY.git (push)

Troubleshooting: No such remote ‘[name]’

This error means that the remote you tried to change doesn’t exist:

$ git remote set-url sofake https://github.com/octocat/Spoon-Knife
> fatal: No such remote 'sofake'

Check that you’ve correctly typed the remote name.

Renaming a remote repository

Use the git remote rename command to rename an existing remote.

The git remote rename command takes two arguments:

  • An existing remote name, for example, origin
  • A new name for the remote, for example, destination

Example

These examples assume you’re cloning using HTTPS, which is recommended.

$ git remote -v
# View existing remotes
> origin  https://github.com/OWNER/REPOSITORY.git (fetch)
> origin  https://github.com/OWNER/REPOSITORY.git (push)

$ git remote rename origin destination
# Change remote name from 'origin' to 'destination'

$ git remote -v
# Verify remote's new name
> destination  https://github.com/OWNER/REPOSITORY.git (fetch)
> destination  https://github.com/OWNER/REPOSITORY.git (push)

Troubleshooting: Could not rename config section ‘remote.[old name]’ to ‘remote.[new name]’

This error means that the old remote name you typed doesn’t exist.

You can check which remotes currently exist with the git remote -v command:

$ git remote -v
# View existing remotes
> origin  https://github.com/OWNER/REPOSITORY.git (fetch)
> origin  https://github.com/OWNER/REPOSITORY.git (push)

Troubleshooting: Remote [new name] already exists

This error means that the remote name you want to use already exists. To solve this, either use a different remote name, or rename the original remote.

Removing a remote repository

Use the git remote rm command to remove a remote URL from your repository.

The git remote rm command takes one argument:

  • A remote name, for example, destination

Removing the remote URL from your repository only unlinks the local and remote repositories. It does not delete the remote repository.

Example

These examples assume you’re cloning using HTTPS, which is recommended.

$ git remote -v
# View current remotes
> origin  https://github.com/OWNER/REPOSITORY.git (fetch)
> origin  https://github.com/OWNER/REPOSITORY.git (push)
> destination  https://github.com/FORKER/REPOSITORY.git (fetch)
> destination  https://github.com/FORKER/REPOSITORY.git (push)

$ git remote rm destination
# Remove remote
$ git remote -v
# Verify it's gone
> origin  https://github.com/OWNER/REPOSITORY.git (fetch)
> origin  https://github.com/OWNER/REPOSITORY.git (push)

Note: git remote rm does not delete the remote repository from the server. It simply
removes the remote and its references from your local repository.

Troubleshooting: Could not remove config section ‘remote.[name]’

This error means that the remote you tried to delete doesn’t exist:

$ git remote rm sofake
> error: Could not remove config section 'remote.sofake'

Check that you’ve correctly typed the remote name.

Further reading

  • «Working with Remotes» from the Pro Git book

Понравилась статья? Поделить с друзьями:
  • Gimp скачать бесплатно на русском языке для windows 10 64 bit
  • Godex bzb 2 драйвер windows 10 x64
  • Global max tcp windows size windows 10
  • Godaddy studio скачать на компьютер бесплатно для windows
  • Global iris service windows 11 что это