Super Quick Git Setup Guide for OS/X
Join the DZone community and get the full member experience.
Join For FreeFirst, go get the source. Building it on my machine, and even on my mini server was a snap. Here are the commands:
cd /usr/local mkdir src cd src curl -O http://kernel.org/pub/software/scm/git/git-1.7.1.1.tar.bz2 tar -xjvf git-1.7.1.1.tar.bz2 cd git-1.7.1.1 ./configure --prefix=/usr/local make sudo make install git --version
Should take a few minutes.
Then, go make a project. I created a java one with a maven archetype, then this morning I did one for Xcode. If you are going to use git with Xcode, you will want to create a .gitignore with the following inside:
# xcode noise *.mode1v3 *.pbxuser *.perspective *.perspectivev3 *.pyc *~.nib/ build/* # osx noise .DS_Store profile
and a .gitattributes file with the following inside:
*.pbxproj -crlf -diff -merge
Then, I ssh'ed into my remote machine. I know git is distributed, but there are still a lot of reasons to have a place that has a copy of the code that everyone can get to.
I made a directory on the mini for all repositories and made a site: repositories.<domain name>. Then I created several subdirectories for grouping my repos. For each subdirectory, I made a security realm. So I can finally have domain model stuff in one place, analytics stuff in another, and have granular control over the permissions! The setup in the mini was super simple and clean. Back to the flow of setting up this one repository.. Once I ssh'ed in, I go to the directory where I want to put the new repo, and do:
sudo mkdir <projectname>.git cd <projectname>.git git init --bare git update-server-info
Then, you have to back out of the dir you are in and chown all dirs and their contents to your www user. My command was:
sudo chown -R _www *
Now we can go back to the window with the local repo and do:
Then, there are a bunch of tutorials that cover the basic sequence of git. Here are the commands to add your project to the repo:
git init git add . git commit -m "Initial commit." git remote add origin https://<path to repo> git push origin master
and we are done. Per my earlier posts, you have to get over the ssl issue by either adding ssl to curl and getting it to see your cert or disabling ssl checking.
Git gets high marks for the way they implemented their commands and they way the app responds to those commands: if you bone up commands, it even suggests what you might mean sometimes. Heuristics are important, but you will still need a cheat sheet. It's also very communicative so you rarely are left wondering if what you did worked or where you ended up.
From http://www.jroller.com/robwilliams/entry/super_quick_git_setup_guide
Opinions expressed by DZone contributors are their own.
Comments