Over a million developers have joined DZone.

Super Quick Git Setup Guide for OS/X

· Java Zone

Easily build powerful user management, authentication, and authorization into your web and mobile applications. Download this Forrester report on the new landscape of Customer Identity and Access Management, brought to you in partnership with Stormpath.

First, 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

The Java Zone is brought to you by Stormpath—a complete, pre-built User Management API. Want to learn how to use JWTs to protect microservices from CSRF and more? Check out this on-demand webinar with our Java Developer Evangelist, Micah Silverman.

Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}