28

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
  • 996
  • 1
  • 10
  • 26
  • Did you create this repository? – Oluwafemi Sule Jun 15 '17 at 09:03
  • 2
    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
  • 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

5 Answers5

31

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
  • 4,797
  • 1
  • 35
  • 32
  • 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
  • 1
    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
25

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
  • 264
  • 3
  • 5
21

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,458
  • 1
  • 11
  • 28
user2251965
  • 351
  • 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
  • 3,969
  • 4
  • 29
  • 46
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
  • 915
  • 1
  • 10
  • 24
  • 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