DEV Community

Cover image for Installation and Setup Git
Narsi Bhati
Narsi Bhati

Posted on

Installation and Setup Git

Welcome to the Git Course.

Thank you for choosing to learn Git with me. This course provides a solid foundation in version control, helping you manage your projects efficiently. If you find this course helpful, please leave a ⭐️ on my GitHub.

banner

What is Git

Git is a free, open-source distributed version control system designed to handle projects of all sizes quickly and efficiently. It helps developers track changes in their code, collaborate with others, and manage different versions of a project over time.

Key Features of Git:

  1. Version Control: Tracks changes to files, allowing you to revert to earlier versions if needed.

  2. Distributed System: Every developer has a complete copy of the repository, enabling offline work and better data security.

  3. Branching and Merging: Supports parallel development by letting you create separate branches for features or fixes, then merge them back into the main codebase.

  4. Collaboration: Git enables teams to work together efficiently by managing code contributions and resolving conflicts.

  5. Speed and Efficiency: Optimized for performance, even with large projects.

Installation and Setup Github :

banner

Windows / Linux (Ubuntu)

sudo apt install git-all
Enter fullscreen mode Exit fullscreen mode

MacOS

brew install git
Enter fullscreen mode Exit fullscreen mode

After installation, you can check if Git is installed.

git --version
Enter fullscreen mode Exit fullscreen mode

banner

Official Manual of Git

 man git
Enter fullscreen mode Exit fullscreen mode

Navigation Shortcuts:

q : Quit the manual and return to the terminal.

j : Move one line down.

k : Move one line up.

d : Scroll half a page down.

u : Scroll half a page up.

Search Shortcuts:

/<term> : Search for a specific term in the manual.

n : Go to the next occurrence of the search term.

N : Go to the previous occurrence of the search term.

banner

Steps for Quick Git Configuration

1. Check Current Configurations

Run these commands to check if your Git identity is already set:

git config --get user.name
git config --get user.email
Enter fullscreen mode Exit fullscreen mode

2. Set Your Identity

If the values aren’t set, use the following commands to add them globally (replace with your details):

git config --add --global user.name "github_username_here"

git config --add --global user.email "email@example.com"
Enter fullscreen mode Exit fullscreen mode

3. Set a Default Branch

Configure Git to use <branch> as the default branch for new repositories:

git config --global init.defaultBranch <branch>
Enter fullscreen mode Exit fullscreen mode

Verify Your Configuration

To ensure your settings were saved, check the contents of your global configuration file:

 cat ~/.gitconfig
Enter fullscreen mode Exit fullscreen mode

Example Output (~/.gitconfig):

[user]

    name = github_username_here

    email = email@example.com

[init]

    defaultBranch = master
Enter fullscreen mode Exit fullscreen mode

Top comments (0)