@@ -4,6 +4,15 @@ If you work with multiple different identities on a single Git hosting service,
4
4
you may be wondering if Git Credential Manager (GCM) supports this workflow. The
5
5
answer is yes, with a bit of complexity due to how it interoperates with Git.
6
6
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
+
7
16
## Foundations: Git and Git hosts
8
17
9
18
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
86
95
accounts. These commands are documented in the [ command-line usage] [ cli-usage ]
87
96
or by running ` git-credential-manager github --help ` .
88
97
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
89
122
[ cli-usage ] : usage.md
0 commit comments