I'm working on a freelance project. The client (let's call him foobar) asked me to upload the code using his github account (my work PC runs 64-bit Windows 10, I have git 2.15.0) installed.
So I did these steps.
Go to Credential Manager -> Windows Credential -> Generic Credentials. Removed my Github account
On the source code directory, performed the standard procedure:
git init
git add *
git commit -m "first message"
git remote add origin https://github.com/foobar/supersecretproject.git
git push -u origin master
A Github credential dialog appeared. Entered his credential.
Wait for a while, and yes the code was commited to Github. Opended the Github page, and strangely the commiter shown was me, not foobar. Strange. How to fix this? I want to commit as foobar.
If you only want to create a single commit on behalf of another author (not to be confused with another committer) and do not want to edit your config, you can also specify the --author argument instead:
git commit --author "Elon Musk <[email protected]>"
This will only set the author metadata of the commit, not the committer metadata about yourself. However, I would even consider this idiomatic as while the correct authorship is maintained, tracing the commit back to you in case of any troubles is still possible.
Found here.
If you wish to change config settings for just one repo. You can try this procedure:
1) On the terminal, change the current working directory to the local repository where you want to configure the name and email that is associated with your Git commits.
2) $ git config user.name "Elon Musk".
3) $ git config user.email "[email protected]"
3) Confirm that you have set the Git username and email correctly:
$ git config user.name
> Elon Musk
$ git config user.email
> [email protected]
It's done!:)
Hope this might help!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With