Technology Guides and Tutorials

How to install Git and Github on OSX and Ubuntu

Git and Github are powerful tools for version control and collaboration. This guide will show you how to install and use Git and Github on both OSX and Ubuntu operating systems. Learn how to set up your repositories, manage your code, and collaborate with other developers. Get the most out of Git and Github on OSX and Ubuntu today!

Why use Git and Github?

Using Git and Github offers several benefits, including:

  1. Version control: Git enables developers to keep track of changes to their codebase over time, allowing them to revert to earlier versions of their work if needed.
  2. Collaboration: Github provides a platform for developers to collaborate on code, work on the same project from different locations, and merge changes into a single codebase.
  3. Code sharing: Github provides a platform for developers to share their code with others, making it easier to contribute to open source projects and collaborate with other developers.
  4. Workflow: Using Git and Github can help developers streamline their workflow, reduce errors, and improve productivity.

Installing Git on OSX and Linux

Installing Git on OSX and Linux is a straightforward process. Here are the steps to install Git on each operating system:

how to install github CLI on osx

brew install gh
brew upgrade gh
gh auth login --web
# for headless:
# gh auth login --with-token
# echo "token" | gh auth login --with-token

install github CLI on linux ubuntu

set github tokens to login to github via cli

Using Git and Github

Once you have Git installed on your machine, you can start using it with Github. Here are the basic steps for using Git and Github:

create local git repo and github project

# change to your github account username:
# set current dirname as project name
GH_NAME=`basename "\`pwd\`"`
git init
git add .
# Adds the files in the local rep and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'.
git commit -m "init"
# create a repository under your account using the current directory name
gh repo create $GH_NAME --private
#wait a while
sleep 2
git branch -M main
git push -u origin main

create local repo

git remote add origin  <REMOTE_URL> 
# Sets the new remote
git remote -v
# Verifies the new remote URL

push to github

$ git push -u origin main
# Pushes the changes in your local repository up to the remote repository you specified as the origin

create git repo and add to existing github project

git init
git add
git commit -m "first commit"
git remote add origin
git push -u origin master


In conclusion, Git, Github, OSX, and Linux can work together to help developers streamline their workflow and enhance productivity. By using Git and Github, developers can take advantage of version control, collaboration, and code sharing, which can help reduce errors and improve productivity.



, , , ,



Leave a Reply

Your email address will not be published. Required fields are marked *