41

How to remove contributor from showing in the main page of project:

enter image description here

Link https://help.github.com/articles/removing-a-collaborator-from-a-personal-repository/ says it possible in settings, but I dont see any collaborator in there:

enter image description here

user6827096
  • 1,186
  • 1
  • 11
  • 26
  • Did you create this repository? – Oluwafemi Sule Jun 15 '17 at 09:03
  • 4
    Possible but people are going to scream at me. Clone a local copy, delete the Github repository. Delete the `.git` folder in your local repository. Then initialize a new repository locally `git init`, then create a new Github repository and push your new local repository up to it. This obviously removes all history! – Ari Feb 01 '21 at 09:06
  • 1
    This is something Github should consider. Something like this can be implemented, repo owner asks the contributor that i want to remove your name from showing up on the repo main page, and then contributor can either accept or reject that. – Badmaash Oct 14 '21 at 08:36

11 Answers11

50

The below method works in my case at least.

  1. On GitHub web page, change a branch name (main --> main1 for example). It updates a contributor list on my GitHub repository dashboard.
  2. Then change it back (main1 --> main).

I have multiple GitHub accounts for different projects. Each for different community. But accidentally, I pushed a commit using a wrong account. I changed the author of the commit, but the wrong account was still on the contributor list on GitHub dashboard. My method keeps commit history as well as GitHub action settings and issue history. But I did not check if pull requests are kept.

www_runner
  • 555
  • 4
  • 6
  • 7
    Can confirm this worked beautifully. This is very useful after detaching a forked repo from the original via GH support. – grandchild Oct 26 '21 at 20:56
  • 7
    Worked for me having removed "bad" commits with wrong account as author. – Ed_ Nov 24 '21 at 09:19
  • 5
    Changing branch names didn't work for me. – Bugs Happen Dec 30 '22 at 16:02
  • It worked for me as well. So the steps to follow are 1) use a `git rebase` method to remove commits from that contributor and then 2) rename the main branch and 3) rename it back. Thanks a lot @www_runner for your comment! – Benjamin RAIBAUD Jul 20 '23 at 15:36
34

You cannot (at least without rewriting history - which is highly unrecommended).

Those users have commits in your repository history, and therefore lines of code have been added by them. Even if you remove all their lines of code they will still show as a contributor.

Contributors are not collaborators.

Collaborators are contributors authorized by the repository owner to have direct (usually write) access to the repository, meaning they don't need to fork the repository and they can be assigned to issues among other things.

Peter Reid
  • 5,139
  • 2
  • 37
  • 33
  • What happens if you revoke their access but keep their commits, are they then removed from that number on the main page? If not, what if you also remove or rename their commits? – Lasse V. Karlsen Jun 15 '17 at 10:56
  • If you revoke their access no. If you remove their commits I would believe so, renaming them perhaps. [But bear in mind the significant impact of renaming and removing commits](https://stackoverflow.com/questions/1491001/what-are-the-practical-consequences-of-rewriting-git-history) – Peter Reid Jun 15 '17 at 10:58
  • I understand all of that, it just seemed to me that you categorically said "No, cannot be done" and your comment now says "Yes, I think you can do it, just do it another way". If his main goal was to get rid of the contributors, it seems to me that there is a way after all. – Lasse V. Karlsen Jun 15 '17 at 10:59
  • Rewriting history in git should really never be done, and as such I will always eliminate it as an option. Even at that I cannot guarantee that it will achieve the desired effect. – Peter Reid Jun 15 '17 at 11:01
  • 3
    this happened to me. I renamed my user id, and someone else took it. I have some entries in the repo as userid@github. Now they are showing up as a contributor, even though they have nothing to do with my project. Very annoying. Github needs to allow you to attribute commits to whoever you want, and not just the user email in the repo history. – Juan Mar 02 '18 at 02:37
  • @Juan the whole point of user email in git is for who authored it. Though newer GitHub emails include the user id so is probably safe from username changes. – qwr Oct 21 '21 at 22:07
  • I've removed the user from history and yet they're still showing as a contributor. It's just my work user vs my personal one, accidentally committed under the wrong name. Very annoying. – Shardj Apr 01 '23 at 02:54
23

I accidentally pushed a commit from an old account. The old account remained on the contributors' list even after I had removed the commit. I had to remove the old account from GitHub to make it disappear from the list.

Vüsal
  • 2,580
  • 1
  • 12
  • 31
user2251965
  • 371
  • 2
  • 9
7

You cannot remove it, but you can change their name (to yours). Yet, I would strongly advise not to, because this would affect all other collaborators and contributors (see below).

This is described in detail here. In short, you have to use filter-branch, e.g. through the following script:

git filter-branch --env-filter '
if [ "$GIT_AUTHOR_NAME" = "OLD NAME" ]; then \
    export GIT_AUTHOR_NAME="NEW NAME" GIT_AUTHOR_EMAIL="new.name@mail.com"; \
fi
'

The reason why better not - it comes with some serious side effects, such as invalidating all subsequent commit hashes, as also mentioned by Peter Reid.

Dimitar
  • 4,402
  • 4
  • 31
  • 47
4

Assuming, it is being done with all the right intentions and, you are the owner of repository - you can use rename feature on repository. Essentially, create replica of repository and swap repository names like you swap variables with steps below.

  1. Create a new replica repository

  2. Copy the cherry picks from original repository which have only the commits with intended authors.

  3. Rename the original repository to to_be_deleted and replica to original.

Commits from original repository can be picked with following steps.

  • git remote add repo2 https://github.com/mygit/original.git
  • git pull repo2
  • git cherry-pick <commit>
  • git push

Contributors are essentially the authors of any commit in the repository. I once accidentally put a wrong email in Author list of a commit in my repository and github started showing a new contributor in the repository. I tried reverting the commit but it didn't help. Finally I had to create / rename /delete original repository.

ViFI
  • 971
  • 1
  • 11
  • 27
  • Exactly my scenario - but what does repo2 refer to? – Colin Sep 15 '20 at 16:13
  • `repo2` is simply the local name of remote repository from which you will be pulling in the commits. – ViFI Sep 15 '20 at 17:47
  • When you say "replica" repository, do you mean just an empty repo to which you will push the cherry picked commits or an actual mirror repo? – Pasha Skender Apr 28 '21 at 14:34
  • @PashaSkender : Yes just a new empty repository. – ViFI Apr 29 '21 at 22:43
  • @ViFI I am a novice in git. I tried your solution. Does cherry-picking commits preserve previous commit details like dates? In my case, it didn't. The commit dates in the new repo got overwritten by today's date. Am I doing something wrong? – Shourya Shikhar Dec 03 '21 at 13:29
4

It is possible but might be challenging.

You need to rewrite history (which is not recommended usually).

How to do it?

  1. You should rewrite all the history commits of the contributor and change the commits to a different author. There are some ways to do it, I found the simplest is by executing amend on an existing commit with changing the author. e.g: Bellow a commit pick you should write:
    exec git commit --amend --author="{NewAuthorName} <{NewAuthorEmail}>" -C HEAD
    
    Watch this explanation https://www.youtube.com/watch?v=7RZgtT4cbw0.
  2. After the contributor doesn't have any commit in the history - update any GitHub setting to refresh the list and then wait for a couple of minutes. For example, you may update the default branch name under your repository => Settings => Code and automation => Branches => Default branch. And then return the original branch name.

After both updates, wait a couple of minutes and it should remove the contributor from the list.

Misha Zaslavsky
  • 8,414
  • 11
  • 70
  • 116
4

Change repo visibility in GitHub repository settings from public to private and then private to public again.

Note:-

In order to make this work you must not have anything related to that user linked with the repo like commits, releases, commits in other branches, or tags.

Caution:-

You will lose all of your repo stars and watchings. First, use other less risky methods if you care about stars.

sanket kheni
  • 1,482
  • 2
  • 12
  • 29
  • 1
    This word around is not working! – Biswadeep Sarkar Sep 02 '22 at 21:15
  • Then you must have a commit or something related to that user linked with the repo. You should remove all the things related to that user from the repo. then try this again. – sanket kheni Sep 03 '22 at 05:32
  • 1
    This have worked for me. Just had one commit from a wrong account. I first removed it from the branch and then I've push forced the branch to rewrite it in the remote server. Then I've changed the repository visibility and it did the trick. Thanks! – Vitor Jul 18 '23 at 11:10
  • 2
    Only working solution for me (August 2023) – thc Aug 04 '23 at 22:14
1

None of the answers here worked for me. What I did and worked:

  1. Changed all commits emails (two) that pointed to the other account using git-filter-repo tool, like this.
  2. Follow the suggestion of renaming the branches, main -> main1 -> main (didn't work, at least not instantaneously).
  3. Returned to the repo about two or three hours later and it was correct.

Perhaps the second point is not necessary.

marcelocra
  • 2,094
  • 2
  • 24
  • 37
0

Fix commits showing a user who copied/cloned a repo

I came to this question because I thoughtlessly worked on a copy of my repo that a colleague had downloaded, instead of my local copy.

I hadn't changed the GIT email for the copy of my repo he’d downloaded as I'd (dumbly) copied the repo from his download, so my pushes to GitHub were all attributed to his account, from his email address set (unwittingly) by him (in the ‘.git’ folder) when he logged into GitHub and downloaded my repo.

Once I’d checked and changed the email for that repo to mine (see the two commands below, executed while in the repo’s directory), my pushes were correctly attributed:

git config user.email
git config user.email myemail@mydomain.com

Unfortunately, he can’t be removed as a contributor to some of these commits without a lot of fiddling, but he’s a trusted colleague and friend so I can live with that.

Dave Everitt
  • 17,193
  • 6
  • 67
  • 97
0

Workaround tested 2022

(Please create appropriate backups before doing any of this)

Assuming that there are not many commits after the commit made by contributor you want to remove.

  1. Download Github for Desktop
  2. Create a dummy folder and point Github for Desktop to the dummy folder when it asks for a location to clone the repo (Do not use your working directory)
  3. Once you clone the repo, you should see history tab, select the commit (assuming the latest one is from contributor you want to remove) and select option for 'revert this commit'
  4. Force push this change to Github
  5. Now that the there are no commits from the user in the main branch
  6. Create a new branch from the default branch and navigate to Settingg of the repo on github.com
  7. On settings page change the default branch to the new branch you created
  8. Since this new branch does not have commits from the contributor to be removed you will force github.com to refresh the contributor list automatically and the contributor will removed.
  9. Now you can change the default back to the old branch (usually master/main) and you will find the contibutor removed from the refreshed list.

TL;DR : Revert Changes to stage where there are no contributions by user to be removed ---> Create a new branch and make it default, this is to force github.com to refresh contributor list ---> Change the setting back to old branch as default. You can delete the temporary new branch you created.

rohit_
  • 21
  • 6
0

3 steps

  1. Remove all branches that that user might have contributed to

  2. Do any number of things to remove all commits related to that author from your remaining branches. Some of your choices:

    1. rebase or interactive rebase and force push
    2. filterbranch and force push
    3. cherry-pick and force push
    4. squash and force push
  3. Turn you repo private, then turn it public again

Justin Ohms
  • 3,334
  • 31
  • 45