Using Git Better - Part 1

Photo by Yancy Min on Unsplash

Using Git Better - Part 1

Learn how to use Git commands Better - Part 1

·

1 min read

Table of contents

No heading

No headings in the article.

We will learn how to use Git better on your machine

  • Check what settings are already present:

    git config --list --show-origin
    
  • Chaging the default branch name to main:

    git config --global init.defaultBranch main
    
  • Setting and Using Git Aliases:
    git config --global alias.last 'log -1 HEAD'
    
  • Usage: git last
  • Switch to an existing branch: From Git 2.23 onwards
    git switch testing-branch
    
  • Create a new branch and switch to it:: From Git 2.23 onwards
    git switch -c testing-branch
    
  • Return to your previously checked out branch: From Git 2.23 onwards
    git switch -