DEV Community

Vignesh . M
Vignesh . M

Posted on

GIT

Git Installation Commands
Step 1: Update the System

  • Run these commands to update your system’s package list and install the latest versions of packages.
sudo apt update
sudo apt upgrade
Enter fullscreen mode Exit fullscreen mode

Step 2: Finish the Git Installation

  • Use this command to install Git along with additional packages.
sudo apt install git-all
Enter fullscreen mode Exit fullscreen mode

Step 3: Verify Installation

  • Use the below command to varify the installation of Git version
git --version
Enter fullscreen mode Exit fullscreen mode

Basic Git Commands with Examples

1. Checking Git Version

  • Before starting with any Git operations, it’s essential to check if Git is installed correctly on your system. The following command will show you the version of Git installed:
git --version
Enter fullscreen mode Exit fullscreen mode

*2. Initializing a Git Repository (git init)
*

  • To start tracking a project using Git, you need to initialize a new Git repository in your project directory.
  • Initialize Git Repository: Once you're in the project directory, run the following command to initialize a Git repository:
git init
Enter fullscreen mode Exit fullscreen mode

3. Git Configuration

  • After that, configure your username and email:
git config --global user.name "your Name"
git config --global user.email "your.email@example.com"
Enter fullscreen mode Exit fullscreen mode
  1. Adding Files to Staging Area
    • When we get to know which files are not added by typing git status(red-colored files are not added).
    • To track a file or prepare changes for commit:
git add <file_name>
Enter fullscreen mode Exit fullscreen mode
  • To add all Files:
git add .
Enter fullscreen mode Exit fullscreen mode
  1. Committing Changes
    • Files displayed in green are staged but not yet committed. To commit these changes, use:
git commit -m "Your commit message"
Enter fullscreen mode Exit fullscreen mode

6.Pushing Changes to GitHub

  • To upload commits to your forked repository
git push origin <branch_name>
Enter fullscreen mode Exit fullscreen mode

REFERED LINKS

  1. https://www.geeksforgeeks.org/basic-git-commands-with-examples/

Top comments (0)