Git, Github CLI, and aliases

Git, Github CLI, and aliases

·

3 min read

Starting with Git

1. Download Git

  • Go to the official Git website: git-scm.com.

  • Click on the Download for Windows button.

  • Once the download is complete, open the installer.

2. Install Git

  • Run the Installer: Double-click the downloaded .exe file to start the installation.

  • Follow the Setup Wizard: Accept the default settings or customize them according to your preferences.

  • Complete Installation: Wait for the installation to finish and click Finish.

3. Verify Installation

  • Open Command Prompt (press Win + R, type cmd, and press Enter).

  • Type:

      git --version
    

    If Git is installed, you will see the version number.

4. Configure Git

  • Open Command Prompt or Git Bash (installed with Git).

  • Set your name:

      git config --global user.name "Your Name"
    
  • Set your email:

      git config --global user.email "youremail@example.com"
    
  • Verify the configuration:

      git config --list
    

Now Let’s Set Up GitHub CLI

1. Install GitHub CLI

  • Go to the GitHub CLI website.

  • Download the installer for your operating system.

  • Run the installer and follow the on-screen instructions.

2. Verify Installation

  • Open your terminal (Command Prompt, PowerShell, or Git Bash) and run:

      gh --version
    

    You should see the installed version of GitHub CLI.

3. Authenticate with GitHub

  • Run the authentication command:

      gh auth login
    
    • You will be prompted to log in via the browser.

    • Follow the instructions to complete the authentication process.

Now Understand Why I Asked You to Set Up GitHub CLI

Process of Creating a Repository and Pushing Without Using GitHub CLI

  1. Manually Create a Repository:

    • Log in to your GitHub account.

    • Click on the New button to create a new repository.

    • Fill in the repository name, description, and other details.

    • Click Create Repository.

  2. Push to GitHub:

    • Initialize a local repository:

        git init
      
    • Add and commit your files:

        git add .
        git commit -m "Initial commit"
      
    • Link your repository:

        git remote add origin <repository-URL>
      
    • Push your code:

        git push -u origin main
      

Process of Creating a Repository and Pushing With GitHub CLI

gh repo create
  • this command will start creating a new GitHub repo and ask you all the questions to set it up

Now Let’s Set Up an Alias

What Is Alias?

An alias is a shortcut for a command or a series of commands. It simplifies repetitive tasks by allowing you to use a shorter or more intuitive command.

How It Makes Life Easy

Using aliases:

  • Saves time by reducing typing effort.

  • Reduces the chances of errors by standardizing commonly used commands.

  • Helps in creating custom workflows.

How to set up aliases?

watch this YouTube video to learn how to set an alias - better with a yt video, trust me

These are some aliases you can set up to make your work faster

function gam { git add .; git commit -m $args }
function gp { git push }
function yd { yarn dev }
function yi { yarn install }