Setting Up a Remote GIT Repository on Windows Server
Overview
I’m not sure if this will ultimately be something that I will use, but I’m thinking of moving away from Perforce and using GIT instead. The description of using GIT to apply patches makes a whole lot more sense now that I’m using these shared libraries for all of the PHP sites.
references
- GIT Reference
- GIT Tutorial
- GIT User's Manual
- Guide for setting up GIT on Windows
- Setting up a GIT server on a Windows server (Copy saved on littledamien.com)
- Illustrated Guide to GIT on Windows
- There are useful articles on GIT on this blog, e.g. Better GIT with PowerShell
- Posh-Git prompt enhancement for GIT on Windows PowerShell
- Rails installer for Windows: http://rubyforge.org/frs/?group_id=5288&release_id=46336
- Ruby tutorial: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book
Setting up GIT, from the Ruby on Rails tutorial
First time system setup
Setting your identity locally:
$ git config --global user.name "Your Name" $ git config --global user.email youremail@example.com
Set up command aliases (in this case “git co” becomes an alias for “git checkout”):
$ git config --global alias.co checkout
Set the editor for Git commit messages, making sure to use a flag so the editor stays attached to hte shell:
$ git config --global core.editor "mate -w"
First-time repository setup
Navigate to the root directory of the repository.
$ git init Initialized empty Git repository in /Users/mhartl/rails_projects/first_app/.git/
Add the project files to the repository.
Create a .gitignore file, which will specify all the files that should not be tracked by Git. (With Rails apps, Rails creates a skeleton .gitignore automatically.)
Add all the files in the current directory to Git
$ git add .
This command adds the project files to a staging area, which contains pending changes to the project. To see which files are in this staging area, use the status command:
$ git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: README # new file: Rakefile . . .
Editing, Working with GIT
Commit changes (locally) with
$ git commit -m "Initial commit" [master (root-commit) df0a62f] Initial commit 42 files changed, 8461 insertions(+), 0 deletions(-) create mode 100644 README create mode 100644 Rakefile . . .
The -m flag allows you to add a comment; if you omit -m, Git will open the commit editor and you will have to enter your comment there.
Git is unique in that it divides commit into two logical steps: a local recording of the changes (git commit) and a push of hte changes up to a remote repository (git push).
To see a list of commit messages, use the log command. Type q to break out of the git log if it is long.
$ git log commit df0a62f3f091e53ffa799309b3e32c27b0b38eb4 Author: Michael Hartl <michael@michaelhartl.com> Date: Thu Oct 15 11:36:21 2009 -0700 Initial commit
Push code to remote Git repository (GitHub, for example).
Create a new repository on the remote server.
Push the application to the remote repo:
$ git remote add origin git@github.com:<username>/first_app.git $ git push origin master
These commands tell Git that you wnt to add GitHub as the origin for your main (master) branch and then push your repository up to GitHub.