Skip to content

Commit 28b2091

Browse files
committed
docs: add TL;DR section on how to update remote URL
1 parent 5fe5b35 commit 28b2091

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

docs/multiple-users.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ If you work with multiple different identities on a single Git hosting service,
44
you may be wondering if Git Credential Manager (GCM) supports this workflow. The
55
answer is yes, with a bit of complexity due to how it interoperates with Git.
66

7+
---
8+
9+
**Prompted to select an account?**
10+
11+
Read the [**TL;DR** section][tldr] below for a quick summary of how to make GCM
12+
remember which account to use for which repository.
13+
14+
---
15+
716
## Foundations: Git and Git hosts
817

918
Git itself doesn't have a single, strong concept of "user". There's the
@@ -86,4 +95,28 @@ You can use the `github [list | login | logout]` commands to manage your GitHub
8695
accounts. These commands are documented in the [command-line usage][cli-usage]
8796
or by running `git-credential-manager github --help`.
8897

98+
## TL;DR: Tell GCM to remember which account to use
99+
100+
The easiest way to have GCM remember which account to use for which repository
101+
is to include the account name in the remote URL. If you're using HTTPS remotes,
102+
you can include the account name in the URL by inserting it before the `@` sign
103+
in the domain name.
104+
105+
For example, if you want to always use the `alice` account for the `mona/test`
106+
GitHub repository, you can clone it using the `alice` account by running:
107+
108+
```shell
109+
git clone https://[email protected]/mona/test
110+
```
111+
112+
To update an existing clone, you can run `git remote set-url` to update the URL:
113+
114+
```shell
115+
git remote set-url origin https://[email protected]/mona/test
116+
```
117+
118+
If your account name includes an `@` then remember to escape this character
119+
using `%40`: `https://alice%[email protected]/test`.
120+
121+
[tldr]: #tldr-tell-gcm-to-remember-which-account-to-use
89122
[cli-usage]: usage.md

0 commit comments

Comments
 (0)