1. Download & Install Git on your machine
open up your Terminal / Console and type
git version
if this command is unknown, you have to install git
- Mac / Linux: most likely already installed
- All other operating systems: git-scm.com
2. Setup
With other revisioning systems, it can be quite a hassle to create an initial setup for a folder, with git this is really easy. Just open up your shell, change the directory to the directory you wish to use git and type:
cd myProjectPath
git init
To add a remote git server, type:
git remote add origin ssh://myserver.com
For example, you can use github.com to host your open source projects, or bitBucket.org. You will find an excessive online help on how to setup a remote server on github: How-to-Setup github. Basically, you only need a private/public ssh key and a valid user account.
But remember, you can use git only on your local computer as well, it is not required to have an online server!
Usage
to get the status of your local git repository, query:
git status
to add files you type:
git add myfile.ext
or to add all:
git add *
If you changed something and would like to store these changes as a version, you can "commit" your update:
git commit -a -m "comment about change"
At this point, your commit is only local! You can commit as few or as many changes as you like. But at the end of the day, you should push your changes to the server:
git push origin master
If you are interested in getting the changes from the server to your local machine, type:
git pull
Summary
- git version
- git init
- git remote add origin {ssh://myserver.com} (Add remote Server)
- git status
- git add .
- git commit -a -m "minor changes"
- git push origin master (Push to remote Server; where 'master' is the name of your current branch)