1

I recently added a conditional statement to my .gitconfig I order to use two git profiles. However, now I must append my username to every repo url in order for it to be found.

Added to .gitconfig

[includeIf "gitdir:~/work/"]
        path = ~/work/.gitconfig

When you copy and paste a url directly from Github the url looks like this

https://github.com/user123/my-amazing-project.git

So if I forgot to add the username in while I clone it (which I usually do) I need to run;

git remote add origin https://user123@github.com/user123/my-amazing-project.git

Is there anyway to avoid this?

Kaigo
  • 1,267
  • 2
  • 14
  • 33

1 Answers1

0

Adding the user to the URL should not be linked to the conditional include, but rather be the consequence of using a git config credential helper.

That would allow the HTTPS credentials cache helper to distinguish between userABC@github.com and user123@github.com

And the command would not be git remote add, but:

cd /path/to/repo/already/cloned
git remote set-url origin https://user123@github.com/user123/my-amazing-project.git
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250