Setup your gear for better navigation

How do you setup macOS for Git and any development environment?

Are you preparing for a long drive in you Motor Bike? Well, as an avid traveller I prepare my Motor bike before my long road trip (I’m not doing this anymore due to other commitments I’ve now) If do you want to discuss your road trip idea and experience, feel free to inbox me or get in touch with any my social links below this blog.

In this article I am covering the complete git development preparation for a new developer in all one shot in a macOS just like preparing your Motor Bike before road trip. Most probably this will be one time setup until and then your Mac doesn’t crash and reload macOS again.

Why macOS and why not Linux? In this modern world most software/web developments are happening through macOS. So I am covering macOS preparation to inspire someone else (if really exists human not robot) to write about Linux preparation. Moreover, Linux has various flavors. I’m really confused to choose which flavor at this moment :) At the same time, I’m honored to publish linux preparation article here if you are interested with your author or pen name (inbox me if you are interested).

Various steps

  1. Git Installation
  2. Prepare git work folder and setup
  3. Generate public SSH key to push codes to repo
  4. Install code writer of your choice to write codes

Yes, you read it right these are four major high level steps. But there are various sub steps involved to KISS. To install all these in your macOS you must be an sudo users or root user in UNIX term. So lets start.

Git Installation

There are various way to install Git in MacOS. I give you simple way if you really love code (remember KISS). So lets use macOS inbuilt terminal. The command line is almost 50 years old, but it’s not outdated. Text-based terminals are still the best way to accomplish many tasks, even in the age of graphical desktops and touch-screen gadgets.

First step is to install Homebrew. Homebrew is missing package manager for macOS (or Linux).

macBook:~ ibnunowshad$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Paste that in a macOS Terminal prompt. The script explains what it will do and then pauses before it does it. Just follow screen instrcution in the terminal until the installation completed and come back to macBook:~ ibnunowshad$

macBook:~ ibnunowshad$ brew install git

_This command install git through Homebrew. After installation you can verify the git version through git --version in same terminal.

macBook:~ ibnunowshad$ git config --global user.name "Ibrahim Nowshad"
macBook:~ ibnunowshad$ git config --global user.email "[email protected]"

Above two commands configure git environment globally with your name and email address You are highly encourage to replacing my name and email address to your own.

That’s it first step completed. Pretty easy. Isn’t it?

Prepare git work folder and setup

Generate public SSH key to push codes to repo

SSH keys are generated through a public key cryptographic algorithm, the most common being RSA or DSA. At a very high level SSH keys are generated through a mathematical formula that takes 2 prime numbers and a random seed variable to output the public and private key. This is a one-way formula that ensures the public key can be derived from the private key but the private key cannot be derived from the public key.

SSH keys are created using a key generation tool. The SSH command line tool suite includes a keygen tool.

Execute the following to begin the key creation macBook:~ ibnunowshad$ ssh-keygen -t rsa

Just follow the steps and press return key You may choose to give a passphrase if you need more security.

macBook:~ ibnunowshad$ cat ~/.ssh/id_rsa.pub

Copy the key content from after executing above command and you can paste it in your GitHub or GitLab or Bitbucket profile where appropriate under your account setting.


See also