Git Set Url
2023-02-25
Ah frick, here we go again
I was having an issue pushing to a Git repository. It was saying “remote
not found,” but clearly it exists as I’m able to push to it with the CLI git
(I was using Visual Studio Code’s built-in Git function). The debug log
was very unhelpful, so I did a little bit of digging. As it turns out,
VS Code doesn’t even look at the .git-credentials
file! What a big heck!!
Thonking Emoji
As far as I’m aware, the conventional method is to use GCM (Git Credential Manager) and VS Code will pull creds from that. Unfortunately, I had the worst time of my life trying to sort out a problem between multiple accounts across multiple Git instances when I used GCM. Now, this was very likely user error [TM], but I don’t want to mess with it when there is a simpler solution.
There can only be one. Why am I quoting Highlander >:C
https://[username]:[token]@[Git-Instance]/MyName/MyRepo.git
This one line fixed all of my woes I had been experiencing over the last hour. I hadn’t considered putting an access token in with the remote url, but it definitely works. I don’t like it at all. It’s ugly. It’s not simple to fix unless you know what you’re looking for. But I was aware of set-url and using multiple tokens, but not using them in this particular manner. On the up side, I can do this per repository, too!
But that’s useless! Congratulations!
You bet it is, and it makes me happy. I fixed a problem in a very ill-advised way, and that’s usually how things get done when you need something to be fixed right away due to more pressing concerns.