Creating a Shared git Repository for your final project

Joseph Colosimo MIT'12

Given that you will be working in teams, we highly recommend using a version control system. There are many reasons for doing so, but the primary reason is that you each person in the team has full control repository. If you commit your code intelligently, you don't have to worry about the situation where you make some series of changes and can't figure out what you changed to cause things to stop working and can't go back to your earlier code. I've already seen this happen multiple times in lab.

So, you and your partner will each have your own repository and when you want to make your changes available to your partner, you'll push your code to a shared remote repository and your partner will pull those changes from this same remote repository. And the same goes for the other way around.

git is an enormously powerful tool and I'm not going to even begin to try to explain how to use it. It is so widely used that you can very easily just google the thing you want to do with it to find out how to do it. I would recommend looking over a few basic tutorials if you are unfamiliar with version control systems. Take a look at the recommendations here: http://sixrevisions.com/resources/git-tutorials-beginners/

It's critical that you have a separate folder where you keep all your verilog code. I've seen a lot of people mixing their code with their project files and I don't recommend this because it can become a total mess, especially if you need to reset your project.

This guide is going to show you how to make the appropriate repositories and hook them up so that you and your partner can share your code.

You and your partner each run (6111-fp ONLY contains your code, not the project data):

    $ mkdir ~/6111-fp
    $ cd ~/6111-fp
    $ git init
You then run:
    $ mkdir ~/6111-fp-repo.git
    $ cd ~/6111-fp-repo.git
    $ fs sa . [Partner's Username] rlidwk
    $ git --bare init
    $ cd ~/6111-fp
    $ git remote add origin ~/6111-fp-repo
    $ echo "test" > test
    $ git add . ; git commit -m "first commit"
    $ git push origin master
Your partner then runs:
    $ cd ~/6111-fp
    $ add [Your username]
    $ git remote add origin /mit/[Your username]/6111-fp-repo
    $ git pull origin master
Now, every time you make a change, when in the 6111-fp directory, do
    $ git status
This will tell you which files you have changed. You may want to only commit certain changes:
    $ git add file1 file2 ...
Or you might just want to commit everything:
    $ git add .
Now, commit
    $ git commit
This will bring up an editor window that will let you say what you changed. Finally, do
    $ git push
To send your code upstream to the shared repo. You don't have to push every time. If you want to make several commits and wait until later to let you partner see your code, you can hold off on pushing. To get your partner's changes, do:
    $ git pull
If you'd like to have a copy of the repo on a personal machine which doesn't have AFS mounted, run (on your machine):
    $ mkdir ~/6.111-fp-remote
    $ cd ~/6.111-fp-remote
    $ git init
    $ git remote add origin username@linux.mit.edu:~username/6.111-fp-repo.git
    $ git pull origin master