79142386

Date: 2024-10-30 18:33:47
Score: 0.5
Natty:
Report link

A less desirable solution that I found is to edit the .git/config file and comment out the url under the '[remote "origin"]' with a '#', then, duplicate it and modify it to have the desired USER and TOKEN.

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
#   url = https://user1:[email protected]/user/repository.git
    url = https://user2:[email protected]/user/repository.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

This way, it is possible to do a git push for example then go back and comment out the url that was added and uncomment the original one.

I am still looking for a more hassle free solution though, as this would leave both tokens in the .git/config file, which is undesirable.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Atti