Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move git repository to another github user

There are many answers on Google that point in the same direction, but when it comes to version control I don't want to try anything and then mess up my repository.

I have set up a repository on GitHub and would like to move it to another user, so that I can close the repository. He would then invite me to the repo once it belongs to his account. I guess this is quite a common use case for working with clients - once you finished the project, you hand it over to them.

Now, assuming this is possible, how would I change my local Git settings in the project so that I am now pushing to/pulling from the new location? And, by moving the repo, would I lose the commit history?

like image 426
weltschmerz Avatar asked Jan 03 '13 01:01

weltschmerz


People also ask

How do I transfer a repository to another account?

If you're using Git, you'll first need to clone the repo you want to copy locally. Then, create a new empty repository in the account you want to add the repo. Finally, add your remote and push the files from the local repo to the new Beanstalk account using the git push command.

How do I transfer ownership of a Git repository?

Transferring a repository owned by your personal accountUnder your repository name, click Settings. Click Transfer. Read the warnings and enter the repository name to confirm that you've done so. Type the name of the new owner and click I understand, transfer this repo.


2 Answers

Any of the following will work:

  • Just transfer ownership of the repo to another user and have them add you as a collaborator.

  • If someone forks your repo, then you delete the original, their fork is still there, unless it's a private repository. they can then add you as a collaborator on their fork repo.

  • Another user can simply clone your repo (commits intact), create a new repo on GitHub, add the new repo's remote info, and push your repo up to their new one. (Then, they can add you as a collaborator.)

like image 70
xero Avatar answered Oct 24 '22 19:10

xero


To answer the questions:

  1. You would not lose anything - not even commit history. The point of Git is that it is decentralized - everybody with a copy of the repository has everything. Just the new repo.

  2. It is easy to change the git settings to push to the new repository. You can either use

    git remote set-url origin git://new.url.here 

    or edit the .git/config file.

I would say you should:

  1. Transfer ownership of the repository (or have the client fork it).
  2. Change your git config to push to the new repository
  3. You're done.
like image 32
citruspi Avatar answered Oct 24 '22 19:10

citruspi