NoW #1: How to set up your Macbook for development?

Setup your dev env on the MacBook.

10/22/20243 min read

A . Setup Git with GitHub

  1. Install Git

  2. Configure Git

  3. Generate SSH Key

  4. Create GitHub Account

  5. Add SSH key to GitHub

  6. Initialize Git Repo

  7. Add files and commit changes

  8. Create Remote Repo on GitHub

  9. Add Remote Repo

Step 1: Install Git:

  • Open Terminal

You can find Terminal in Applications > Utilities, or search for it using Spotlight (Cmd + Space).

  • if Git is already installed:

    • Run the following command:

git --version

  • If Git is installed, it will show the version number. If not, you’ll be prompted to install it.

Install Git (if needed):

  • If Git isn't installed, install it by running Xcode or Homebrew. I prefer brew.

It installs all the command line tools along with Git.

xcode-select --install

  • To install Xcode on a Mac, you can use the Mac App Store:

    • Open the App Store

    • Sign in

    • Search for Xcode

    • Select Install or Update

  • To install homebrew, open terminal and enter the below command:

You should see a message once the installation is complete; however, to verify the installation, type the command → # brew doctor

If your Homebrew installation has been successful, you will see this text: “Your system is ready to brew.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step 2: Configure Git

  • Set up your Git username:

  • Replace Your Name with your name:

git config --global user.name "Your Name"

  • Set up your Git email:

  • Optional: Set up a default text editor (if you prefer a specific one, e.g., VS Code, nano, etc.):

    • Example for setting VS Code:

git config --global core.editor "code --wait"

Step 3: Generate SSH Key

ssh-keygen -t rsa -b 4096 -C "youremail@example.com"

  • Press Enter to accept the default file location.

  • Optionally, add a passphrase (or just press Enter to skip it).

  • Start the SSH agent:

    • Run the following commands:

    • eval "$(ssh-agent -s)"

ssh-add -K ~/.ssh/id_rsa

Step 4: Create GitHub Account

Signup using your email

Step 5: Add SSH Key to GitHub

  • Copy the SSH key to your clipboard:

    • pbcopy < ~/.ssh/id_rsa.pub

    • Go to GitHub.com > Profile Icon (top right) > Settings > SSH and GPG Keys > New SSH Key.

    • Paste the SSH key and save it.

  • Test the SSH connection:

    • Run the following to check if the SSH key is correctly set up:

ssh -T git@github.comYou should see a message like:

Hi username! You've successfully authenticated, but GitHub does not provide shell access.

Step 6: Initialize Git Repo

Go to your project folder on terminal and run the command

git init

Step 7: Add Files and Commit changes

git add .
git commit -m "Initial commit"

Step 8: Create Remote Repo on GitHub

To push your local repository to GitHub, you’ll need to create a new remote repository on GitHub. Follow these steps:

  1. Log in to your GitHub account and click on the “+” icon in the top right corner of the page.

  2. Select “New repository” from the dropdown menu.

  3. Give your repository a name, select “Public” or “Private,” and click “Create repository.”

  4. Copy the HTTPS or SSH URL of your new repository.

Step 9: Add Remote Repo

Finally, you’ll need to add the remote repository to your local Git repository and push your changes to GitHub. Run the following commands in Terminal, replacing <repository- url> with the URL of your remote repository:

git remote add origin <repository-url>
git push -u origin master

Setup Codespaces:

Few commands for use

  • Clone a GitHub repository:

    • Go to a repository on GitHub, click the green "Code" button, select "SSH," and copy the URL.

    • In Terminal, navigate to where you want to store the repository and run:

git clone git@github.com:username/repository.git

  • To see the config: git config --list --show-origin

B. Setup IDE

  • Install Visual Studio Code

  • Install Packages in VSCode

    • Go to Extensions and install

      • GitHub Pull Requests

      • GitHub Codespaces

      • GitHub Repositories

      • GitHub Actions

  • Connect to GitHub from VSCode

    • Go to Remote Explorer in Vscode

    • Select GitHub Codespaces

      • Sign in to GitHub

Continue and Authorize VSCode to access GitHub.

  • If you have MFA setup, you will have to go to mobile and get the Authorization code to get to the below screen.

  • Scroll down and make use of VSCode as the editor preference unless you have other editor preferences.

  • You can go to remote Explorer and clone remote repositories on GitHub to your local environment in VSCode and the local directory.

  • You can also open a local directory in VSCode from the VSCode explorer and make changes, run/debug, stage/commit, and publish to GitHub.