Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I worked on a private repo in GitHub then made it public. Can I make my activity visible?

Tags:

github

repo

I had a private repo for 6 months that I worked on. Today I finally made it public after submitting a paper. Is it possible to make the activity (those green square) visible? I tried clicking on contribution setting and got the message Visitors will now see your public and anonymized private contributions, but the activity still doesn't show.

Update 1:

I noticed that only changes I did on GitHub (the website rather than pushing code from my machine) were recorded. That is, only the readme file shows as I often updated it on the website.

Update 2:

I ran git --no-pager log -s --format="%ae" to see which emails were used for the commits and got the following: Some emails are the primary email under GitHub, some are of the form [email protected], some are [email protected], some are [email protected]_name.edu.

Also, as I mentioned in one of the comments below, if I go to my repo and specifically look at commits I can see something like: Penguin authored and Penguin committed on May 27 1 parent 1d71ac3 commit cb95c2870de67383ee653849b4c7b40a062f5fd3. But this does not show on my activity.

Lastly, some comments mentioned creating a new repo on GitHub and pushing my previous commits (after filtering the emails somehow which I didn't quite understand). However, I already have several Stargazers on this repo and would like to keep them. By making a new repo I believe these will disappear.

Update 3:

I used git filter-repo to change all the emails to my primary email and now all my previous commits emails appear to be my primary email when I call git --no-pager log -s --format="%ae". However, I still don't see the activity showing. For example, if I go to my repo I can see that one of the commits says Penguin authored and Penguin committed on Apr 8, but this doesn't show in the activity.

like image 600
Penguin Avatar asked Oct 11 '21 22:10

Penguin


People also ask

Does GitHub show activity on private repos?

Your GitHub profile shows a graph of your repository contributions over the past year. You can choose to show anonymized activity from private and internal repositories in addition to the activity from public repositories.

Can you fork a private repository and make it public?

No. You can fork it and it still remains private. Private collaborators may fork any private repository you've added them to without their own paid plan. Their forks do not count against your private repository quota.

Can I share a private GitHub repo with someone?

You can invite users to become collaborators to your personal repository. If you're using GitHub Free, you can add unlimited collaborators on public and private repositories. Repositories owned by an organization can grant more granular access.


3 Answers

I noticed that only changes I did on github (the website rather than pushing code from my machine) were recorded.

That means you need to check, from within your local folder of your cloned repository:

git config user.name
git config user.email

Make sure those match your GitHub user account, and GitHub user email.
Then make some new commits, and push: see if the activity is reflected then.

The OP Penguin confirms in the comments:

Looks like the email wasn't the same (for some reason the email was empty in my local machine).

Now I can push commits through my local machine and they appear as activities.

Is there a way to show my previous commits though?

For that, you need to rewrite your past commit, and force push the result (which is OK if you are the only one working on that repository).

See How to switch GitHub account and retrospectively update commit history? for an example, using git filter-repo (with a mailmap map), or git filter-repo --commit-callback.


Which I don't quite understand. If I'll create a new repo and push everything to it I will lose the stargazers

You would not create a new remote repository, only clone it in a new local cloned repo, and apply git filter-repo there.

Once the local history matches what you expect in terms of commit authorship, you force push back to the original remote repository (with all its Stargazers).

git push --force # at least for the main/master branch

From the discussion

I think git push --force worked. I still see the commits on the commit page as not verified, but the activities appear now.
Is that a problem that they are not verified?

And now it appears that whenever I try to push a commit from my local machine I need to authenticate for some reason

The remote authentication is different from commit authorship and verification.

The verified aspect is due to a lack of commit signature, as mentioned here.
You would need to resign your commits locally (still using git filter-repo), and force push them again.
Once signed (with a key registered to your GitHub profile), they would appear as verified.

The git push with authentication depends on which protocol you are using (HTTPS or SSH), as recently (Nov. 2021 at the time of writing) explained by torek in "Easy way to switch between accounts on git in the terminal on Windows?".

like image 78
VonC Avatar answered Oct 09 '22 11:10

VonC


This likely has to with you not having signed off the commits with GPG -
which leads to commits, which are not labeled as (identity) "verified".

The documentation also doesn't cover this case, at least not in detail ... while the most easy might be to create a new one repository, add it as remote and then you can push all the changes. And even when the edits you've made are not publicly visible, GitHub still is your third party witness.

like image 2
Martin Zeitler Avatar answered Oct 09 '22 11:10

Martin Zeitler


Contributions should still be shown in that case. Here are some of the reasons your contributions might not be being shown:

  • GitHub isn't aware of the email address you used in your commit messages

  • The commit wasn't made in the default or gh-pages branch

  • The repo is a forked repo, not a standalone repo

GitHub also mentions that it will not show commits that were made less than 24 hours ago, so it seems like they have some sort of caching mechanism going on with their contribution graph. It may help to wait 24 hours since you made the repo public, to ensure that cache has a chance to roll over.

like image 1
Maximillian Laumeister Avatar answered Oct 09 '22 10:10

Maximillian Laumeister