Reputation: 14275
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?
Upvotes: 34
Views: 40527
Reputation: 121
This can also be done directly with the desktop version of GitHub on a PC without installing CLI.
As stated above by @citruspi if you edit the config file you're doing what this command does for you manually.
git remote set-url origin git://new.url.here
Does for you if you have CLI.
https://stackoverflow.com/a/14132101/3099982
or edit the .git/config file.
Steps below...
Upvotes: 2
Reputation: 4319
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.)
Upvotes: 30
Reputation: 2421
Why don't you do it within github? Just transfer ownership to the new user. Go to Settings at Github.
Transfer Ownership: Transfer this repo to another user or to an organization where you have admin rights.
Upvotes: 6
Reputation: 6891
To answer the questions:
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.
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:
Upvotes: 14
Reputation: 534925
You would not lose anything. That's the point of git. Every copy of the project has a complete copy of the repo - you have it, github has it, anyone who forks it has it.
The configuration of the remote is just a line in the .git/config file:
url = [email protected]:mattneub/Programming-iOS-Book-Examples.git
You can remove the old remote and create a new one, but the simplest thing is just to edit that line by hand.
There is no mystery here. The .git folder and your repository are directly open to your view.
Upvotes: 0