I've just started using Git for version control on a local network. To allow multiple users to sync repositories I've also started using the Bonobo Git Sever package which works well.
Up until now I've always initialised a repository by creating it in Bonobo, clone it down to a local directory, add files etc then push / pull as required.
Let's now say that I initially create the repository in a local directory, use it for a while and then want to add it to the remote sever, keeping all the commit history intact.
How do i do this? Is there an opposite to git clone - ie take an existing local repository and add it to the remote server?
You'll have to create an empty repository on the server. (make sure it's empty! Some servers will ask you to initialize with a README or .gitignore
or something - you don't want that.) Once you do that, get the url and add it as a remote
:
git remote add origin http://url-to-remote.git
Then do a push
:
git push origin master -u
This assumes you're pushing the master
branch. -u
specifies that your master
should "track" the master
on the server.