If I clone using my personal account, it doesn't work. It says it can't find the repo. Makes sense, the repo is private and my personal account is not in it.
So I use:
git clone https://<token>@github.com/.../....git
with a token I generated on my work github account.
This works.
Now if I make a modification and push (git add .
, git commit -s -m "something"
, git push
), it works, but on the repo, it shows up as if my personal account had made the pushes even though this account does not even belong to the repo. I insist, the token I use is not linked to that personal account.
I'm a bit confused as to what I should do. I think the git credential manager messes things up but I'm not sure how. Also, how does it even work since I shouldn't even have the "rights" to push in that repo with my personal account? Is the token used to bypass security and then what is displayed not even "controlled"? By this I mean does GitHub allow the push event thanks to the token but the commit itself contains author information from the local Git configuration that may not be matching??
I would have preferred to comment but I don't have enough reputation
Not sure of my answer but a few hints that might help to understand.
When you commit, Github use 2 information:
Authentication: This is handled by the token you use. The token is associated with your work GitHub account, which has the necessary permissions to push to the repository.
Commit Author Information: This is determined by the configuration of your local Git environment. It uses the name and email address configured in your Git settings.
It seems that your local Git configuration is using the email address associated with your personal GitHub account.
You can check your Git configuration with:
git config --global user.name
git config --global user.email
Depends on the result you can update it:
git config --global user.name "Right Name"
git config --global user.email "right-email@example.com"
But if you don't want to change your global configuration, you can set the author information for one repositories:
cd path/to/your/repository
git config user.name "Right Name"
git config user.email "right-email@example.com"