Override configured user for a single git commit
You could also set environment variables GIT_COMMITTER_NAME
, GIT_COMMITTER_EMAIL
, GIT_AUTHOR_NAME
, and GIT_AUTHOR_EMAIL
on a per-shell or even per-command basis.
I believe you could run:
git config user.name "Your Name"
git config user.email [email protected]
for different parts of git. Try opening the folder where the work is being done for the repo to the github server.
Make sure that you see a .git folder in that work folder. Now open that folder in Terminal/Console/CommandPrompt and try changing the username and email for that folder only by running the commands I specified above.
By changing that, you may now be able to access the GitHub server.
Take a look here: https://help.github.com/articles/setting-your-username-in-git
Also, I believe there is a way to push to a remote repo by using your github username and password in the command itself, but I'm not quoting it because it didn't work for me.
Try to prepend this to your git command :
git -c [email protected] -c user.name='Your Name'
This is ok for a one-shot, but you could prefer save this in the .git/config file of the local repo you cloned from git. This can be done by running git config
(no --global or --system to make it "local to the repo") or by editing the .git/config
(it's the same syntax as ~/.gitconfig
First, the author is not necessarily the same as the committer. Git tracks both.
To set what name to use for just this repository, you could do:
git config user.name "Your Name"
git config user.email "Your email"
Notice the absence of the --global
option. This will set the configuration in this repository only.
Alternatively, you can do this for only a single command, using the -c
option:
git -c "user.name=Your Name" -c "user.email=Your email" commit ...
But I think it's better to just use the config options above.