August 07, 2021
Recently, one of my PR got merged in React Core. I was over the moon to see it merged and I took a screenshot and shared it on social media. I was quite happy thinking my name would now show up in the contributors’ section in the GitHub repository of facebook/react
. But here is the twist - it was not!
Normally the name shows up in GitHub if you have even one single PR. It got me thinking why wasn't my name on that list. I had configured the SSH correctly for work and private GitHub; then why would this happen?
I had to go back and figure out how GitHub shows the contribution chart.
My findings:
Conditional Configuration
was released to git back in 2017. For future me, I am writing this blog listing all the configurations I need when setting up git in a new machine. Create a key from terminal
ssh-keygen -t ed25519 -C "[email protected]"
eval "$(ssh-agent -s)"
to .zshrc
ssh-add -K ~/.ssh/id_ed25519
Create SSH config in ~/.ssh
folder (example)
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/personal
Host bitbucket.org
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/workkey
In home folder you can add .gitconfig
for different situations
user]
name = Shubham Pandey
email = [email protected] # default email if no config provided
useConfigOnly = true
[includeIf "gitdir:~/mysites/work/"] # For Work folder
path = ~/mysites/work/.gitconfig # use this config file, you can define them in any folder
[includeIf "gitdir:~/mysites/experiment/"] # For Personal folder
path = ~/mysites/experiment/.gitconfig # use this config file
Now create those two configs in their paths. (example for personal folder)
[user]
email = [email protected]
name = Shubham pandey
That's it. Now you have configured two different emails for two different folders, now I can commit in peace. Hopefully, my next PR to react comes sooner.