Git for sharing files and version control

Why git?

Git is the answer to all the above needs. Git is a distributed version control system:

Setting up Bitbucket

There are many options for hosting your central repository; we are recommending Bitbucket since it is free and private.

Using git@Bitbucket on your machine

Using git from the unix command-line

Before using git, you need to tell it who you are. You should only have to do this once on each account that you will use to store local clones. On some systems, you may get a warning if you fail to do this; on others, it may be an outright error that prevents you from commiting your changes. To fix this, use the following two commands, substituting your own name and e-mail address for the placeholders:

After this, you can use the following git commands to manipulate your repository. Note you need to be within the directory tree of your project repository for these commands to work. (See below for creating a repository by initializing an existing project directory.)

Other ways to set up repositories

Resolving Conflicts

What if two team members accidentally overlap on a change to a file? Note that changes to different lines of the same file will automatically be merged, so the only serious conflicts happen when one person commits a change to a line where a previous commit had changed.

Repository etiquette

You should make repository-using as easy as possible for the other people you're working with by only pushing code that compiles. It is also good practice to agree to a common coding style and only push code that has been style checked.

Git resources

The above covers only the most basic git features. You can also branch off a new version, just fetch changes without also merging explictly, rebase your changes over the remote changes, merge branches, stash a particular state, tag a commit with a label to find it later, etc. Ouch, I'm getting a headache from all these options!