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.logcache/*databases/*errors/*sessions/**.pyc*.bakThen, create the repository, and commit the files to it.
git initgit add .git commit -aIf 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.gitgit push -u origin masterI 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 lucaThen, I do some changes. If I create a new file foo.py, I can add it:
git add foo.pyWhen I am satisfied with my changes, or when I want to do a checkpoint, I can do:
git commit -aI can then upload my changes to the repository:
git push origin lucaOnce 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 mastergit merge lucagit push origin masterIf 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 fetchI 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 mastergit merge helengit push origin mastergit checkout lucagit merge mastergit push origin luca