Home / Blog / Git basic Commands for Beginners
git basic commands

Git basic Commands for Beginners

Git Topics

  1. Initializing a Git Repository
    • Creating a New Branch
    • Initializing a Local Git Repository
  2. Adding and Committing Changes
    • Adding Files to Staging Area
    • Committing Changes to Local Repository
  3. Creating and Managing Branches
    • Switching to a Newly Created Branch
    • Creating and Renaming Branches
  4. Connecting to Remote Repositories
    • Adding a Remote Repository
    • Pushing Changes to Remote Repositories
  5. Git Configuration
    • Setting User Information
    • Global Configuration Options
  6. Advanced Git Commands
    • Viewing Commit History
    • Inspecting Changes with git show
    • Resolving Conflicts

Git Commands

Creating a New Branch

To switch to a newly created branch:

git checkout -b <branch-name>
Bash

Initializing a Local Git Repository

Create a new project directory:

mkdir newproject
cd newproject
Bash

Create a new file (README.md in this example):

echo "# create new file #" >> README.md
Bash

Initialize Git in the local repository:

git init
Bash

Adding and Committing Changes

Add the file to the staging area:

git add README.md
Bash

Commit changes to the local repository:

git commit -m "first commit"
Bash

Creating and Pushing to Main Branch

Create the main branch:

git branch -M main
Bash

Connect to a remote repository and push changes:

git remote add origin <remote-url>
git push -u origin main
Bash

Practice Task

Jenkins and Selenium Setup

Jenkins Status Check

To check Jenkins status:

sudo service jenkins status
Bash

Selenium Installation

Locate Selenium:

locate selenium
Bash

Install Selenium:

sudo apt install mlocate
sudo apt-get update
sudo pip install selenium
Bash

Git Configuration

Setting Git User Information

Configure Git with your username and email:

git config --global user.name "temp"
git config --global user.email "[email protected]"
Bash

Additional Git Commands

  • Initialize a Git repository:
git init
Bash

Check repository status:

git status
Bash

View commit history:

git log
Bash

Push changes to a remote repository:

git push -u origin master
Bash

Author: TCF Editorial
Copyright The Cloudflare.

You may also read:

Linux Basic Commands for Beginners

Semantic vs. Partitioned Semantic Networks  in AI

Post navigation