Over a million developers have joined DZone.

Super Quick Git Setup Guide for OS/X

DZone's Guide to

Super Quick Git Setup Guide for OS/X

· Java Zone
Free Resource

What every Java engineer should know about microservices: Reactive Microservices Architecture.  Brought to you in partnership with Lightbend.

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-
tar -xjvf git-
cd git-
./configure --prefix=/usr/local
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

# osx noise

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

Microservices for Java, explained. Revitalize your legacy systems (and your career) with Reactive Microservices Architecture, a free O'Reilly book. Brought to you in partnership with Lightbend.


Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

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.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}