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
If you're using git for the first time, you might want to setup some configuration settings:
git config --global user.name "Max Mustermann" git config --global user.email max@mustermann.de
These two settings help to identify you when you're pushing your files to a remote server.
Git can produce colorful output with some commands; since some people hate colors way more than the rest likes them, by default the colors are turned off. If you would like to have colors in your output:
git config --global color.diff auto git config --global color.status auto git config --global color.branch auto
These settings are global (for your machine), so you only need to do this once.
Adding a Remote git Server
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!
Create or select a folder ("myProject") and change the current directory with the bash command cd
cd myProjectPath
git init
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)