How to turn local source code directory into remote git repo?

1.2k views Asked by At

I have a directory on my Windows machine with some source code that I want to share with a couple of other people to develop it further together. I am thinking of using git, but since I want this repo to be (1) private and (2) free, this seems to rule out using GitHub.

So here's my plan (I am fairly new to git so may not be using the right terminology): 1. Set up a remote machine and give everyone in our group access to it 2. Host the git repo on that machine 3. Hook up IDEs on local machines to that repo

For #1: I set up an AWS account and fired up a micro Ubuntu instance (should be enough since the amount of code is small and we're not planning to run heavy jobs on that instance). For #2: I started by scp'ing my code to the remote machine, so there I now have my code in /home/ubuntu/dev/mycode/.

What do I do next? That is, how do I turn /home/ubuntu/dev/mycode/ into a remote git repo, which I can then clone onto my local machine or hook up to it from IntelliJ or Eclipse?

2

There are 2 answers

0
Animesh Sharma On BEST ANSWER

Important points in your question:

Private repository

Free

Couple of other people

Bitbucket is what you need. Try it.

To push your existing project to bitbucket, this is all you need to do.

Push local code to bitbucket repo

2
Tim Biegeleisen On

Typically I have seen this done in a slightly different way, by first initializing a bare repository on the remote, then configuring and pushing the project from the client:

On the remote

cd /home/ubuntu/dev/mycode/
mkdir your_project.git
cd your_project.git
git init --bare

On the client

cd path/to/your/local/project
git init                                           # initialize local repo
git add *                                          # add all files
git commit -m "First commit"                       # commit all files
git remote add origin <URL to your_project.git>    # tell Git how to find the remote
git push origin master                             # push master branch to the remote

Now your remote will have a master branch with an initial commit containing the project. Git remotes are meant to be pushed to, rather than having commits coming directly from them.