I've added lots of lines to github project, why does it say I only added two? - github

Have a look at the contributors page for this project:
https://github.com/Sahand1993/CraigslistPrice/graphs/contributors?from=2018-04-22&to=2018-05-14&type=a
My username is Sahand1993. If you look at my graph, it says I've only added 2 lines of code. But if you look at the project file called elasticsearch/searcher.py, you'll see that I added that entire file, which is around 200 lines long!
So, why is Github saying I've only added 2 lines?

GitHub matches commits to users via the email address in the commit. You haven't set your email address properly.
I see several commits from sahandzarrinkoub#n157-p198.eduroam.kth.se and sahandzarrinkoub#Sahands-MBP.lan, but only one from sahandz#hotmail.com. This last email address is the one you've registered with GitHub.
If the other email addresses are real email addresses that you own you can add them to your GitHub account and claim those commits. But I don't think they are (certainly the one #Sahands-MBP.lan doesn't look right).
I suggest
Adding any email addresses you plan on using to your GitHub profile.
Setting your email address properly on those two machines, e.g. via
git config --global user.email "sahandz#hotmail.com"
This will enable GitHub to associate new commits with your account.
Adding a .mailmap file to map the wrong email addresses to the correct email address.

Related

Why am I able to push and send/receive pull requests but not on the contributor list in github?

I'm been working in a team of four. I'm in the collaborator list. I'm able to commit, push, send pull requests and merge in our repo. My teammates can see my changes, but everyone is on the contributor list except me.
I double checked my email address, make sure the email I used in my local setting is the same with my default email in the github account.
We have changed the owner of the project once, and I'm still using the old url. Is this the reason for that?
I found the github has a complex rule for you be considered as a contributor. Here's the doc of it.
https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-github-profile/managing-contribution-settings-on-your-profile/why-are-my-contributions-not-showing-up-on-my-profile
You have to commit to the main/default branch or make pull requests. To commit into other branches won't count.
Also, to use the old project url is definately one problem. In the project insight, everyone's profile is linked with their username. While mine is only a username with no user icon.
I think I just accidentally hit into one of the corner cases, but I'm still very confused of this design pattern.

Github transfer contributions from one account to another

I have googled it a lot but didn't find any clear answer if it possible and how to do it.
I have an account from which I have contributions to a private repo. I don't have any repositories.
I want all those contributions to go to my new account (There I have repositories).
Is that possible? Do I still have access to that private repo after transfer the contributions?
You would need to rewrite commits which would create new hashes (the committer's name is part of the data used to calculate the hash).
This would mean all commits that reference these commits (the parent commits also being part of the data used to calculate the hash) would also need to be regenerated (rebase allows this to be done in bulk).
All of this would require forcing pushes as well (so all other contributor's local repositories are going to be impacted).
Even if github can automate some of this, it is a massive impact.
TL;DR: yes, but you probably should accept it is hard to rewrite history.
Guessing from the tags I assume you're talking about GitHub accounts. GitHub calculates contributions based on the author email address used in Git commits, and if there is a GitHub account that uses this email address, your GitHub user name shows up as a contributor. That said, you can associate multiple email addresses with a single GitHub account. So if you unregister your current email address from your old GitHub account, and register the same email address for your new GitHub account, existing contributions will show under your new GitHub account.
Do I still have access to that private repo after transfer the contributions?
That's a totally different question, and the answer depends on whether your new GitHub account was given access to the private repository. The GitHub permissions system is based on the GitHub user name, not on registered email addresses.

How to keep Email on GitHub private, but still make contributions visible?

I have an email which linked to GitHub account and I don't want it to be visible for people. So I set it private like this:
Having this configuration you cannot push changes with your email set in git.
If you set any other string as git email, it will be performed, but in contributions block there will be no contributions visible.
How to keep Email on GitHub private, but still make contributions visible?
If you look in Keep my email address private line, you will see this comment:
We’ll remove your public profile email and use
25605156+yourgithubid#users.noreply.github.com when performing
web-based Git operations and sending email on your behalf.
So if you attach this generated email to your git, changes will be pushed successfully, and you'll see your commits in contribution board.

Pycharm commits to github not shown in my github history

When using username/password combo to commit to my Github account via Pycharm, I don't get green squares (badges) in my Github commit history. Commits are made to my own public repository
This is not that big technological issue but there are people who judge others based on number of those green squares.
Make sure that the email address that you use in your commits matches the email address of your github account. To change the email address, use git config user.email (see here for more information).

Can I associate a GitHub user with his commits by name only, BitBucket-style?

I've seen Github shows name instead of a linked username in commits and I realise that the right thing to do is to link by email. However, I already have a repository with a whole bunch of commits whose email is "none#none".
On BitBucket, I can specify a per-project mapping of committer name to BitBucket account, and this has worked well enough. Is there anything like this on GitHub?
If not, what other options are there, short of leaving the commits unlinked and rewriting the entire history?
You can use .mailmap file in your repo, for mail aliased (as stated in "“Alias” git authors/committers?")
You also can add another email in your Email setting account.
But both solutions don't scale well when several authors use the same none#none email.