This post describes how to setup Git (on Windows), and also describes basic Git commands.
These commands should be sufficient to perform most of Git operations for revision control.
Below shows how to create a new local and remote repository, connecting through SSH.
The environment on the remote repository must have Git installed as well.
Also, this tutorial shows how to setup the post-receive hook.
This is very useful for deploying as it can checkout all files when pushed.
Setup Command Alias (on local)
git config --global alias.commit-all '!git add -A && git commit'
Create a command alias to commits all changes including created and deleted files.
This is just to simplify the commit command (i.e., git commit-all), and only needs to be done once.
Setup Local Repository (on local)
mkdir new-app-dir
cd new-app-dir
git init
Creates an empty repository.
Create .gitignore file and list files to exclude from revision control.
git commit-all -m "commit message"
Commits all changes including created and deleted files.
Setup Remote Repository (on remote)
mkdir new-app-dir
cd new-app-dir
mkdir .git
cd .git
git init --bare
Creates a bare repository.
cd hooks
Create a file called post-receive with the following lines:
Adds an entry for a remote repository using SSH and refer it as remote-name.
git push -u remote-name master
Pushes master to remote-name (using SSH).
git push remote-name
Pushes master to remote-name (after pushing once).
Add all files excluded by .gitignore but needed for the application.
Setting up GitHub Repository
Below shows how to setup a remote repository on GitHub.com.
GitHub provides a great service for maintaining central repositories (free for public repositories).