Go to the directory where you plan to work, and create a .gitignore file containing the file patterns of files and directories you don't want to version. Here is a sample content (this is a good starting point for web2py):
progress.log
cache/*
databases/*
errors/*
sessions/*
*.pyc
*.bak
Then, create the repository, and commit the files to it.
git init
git add .
git commit -a
If you want to work with others, you need to host a copy of your repository somewhere. Bitbucket and github are two popular choices:
For this example, let's use bitbucket. If you go to Navigation > Overview, it will tell you how to push the initial content of your repository to bitbucket:
git remote add origin https://luca_de_alfaro@bitbucket.org/luca_de_alfaro/cmps183-bboard.git
git push -u origin master
I will describe git via the command line, but I also highly recommend using Altassian SourceTree, which provides you with a graphical representation of the repository and a nice GUI.
A typical use cycle is as follows.
I typically work in a branch named luca. First, I create such a branch:
git checkout -b luca
Then, I do some changes. If I create a new file foo.py, I can add it:
git add foo.py
When I am satisfied with my changes, or when I want to do a checkpoint, I can do:
git commit -a
I can then upload my changes to the repository:
git push origin luca
Once all the contributors are happy with the changes I made, they can be merged with the master branch, and the master branch can be updated on the server:
git checkout master
git merge luca
git push origin master
If I work with a person Helen who keeps her changes in a branch called helen, this is how I get her work.
First, I get any updates that may be on the server:
git fetch
I can now see that there are new changes in remotes/origin/helen
I can review the changes, and I can then merge the changes into either luca or master:
git checkout master
git merge helen
git push origin master
git checkout luca
git merge master
git push origin luca