Free Git Tutorials for devops training in kolkata

Welcome to our in-depth Git tutorial article. In this guide, we’ll explore Git, the versatile version control system that has transformed collaborative software development. Whether you’re a seasoned developer or a beginner, our free Git tutorials will empower you with the skills to excel in using this indispensable tool. Let’s get started!

What is Git?

Git, a distributed version control system, has become an indispensable tool for software developers, enabling efficient collaboration, tracking changes, and ensuring code integrity. Think of Git as the conductor of a symphony in the world of software development. It’s a distributed version control system, acting as the maestro that orchestrates seamless collaboration among musicians (developers). Git ensures that everyone in the orchestra (development team) plays in harmony by tracking every note (code change), preserving the symphony’s integrity, and making it possible to revisit and fine-tune the performance with precision.

In this article, we’ll explore Git’s fundamental concepts and provide you with a handy command cheat sheet to help you navigate Git effortlessly.

Git Basics

Before diving into the command cheat sheet, let’s grasp the key concepts:

Repository: A Git repository is a project’s storage location, where all files, version history, and metadata reside.

Commit: A commit records changes to the repository. Each commit has a unique identifier, a commit message, and references the previous commit, forming a commit history.

Branch: A branch is an independent line of development. Developers create branches to work on features or bug fixes without affecting the main codebase.

Clone: Cloning a repository means creating a copy on your local machine, allowing you to work on it without affecting the original.

Pull: Pulling updates from a remote repository fetches the latest changes and merges them into your local branch.

Push: Pushing commits to a remote repository uploads your local changes, making them accessible to others.

Other version control tools similar to Git:

There are several version control tools similar to Git, each with its own features and capabilities. Here are some notable version management tools:

  1. Mercurial (Hg):
    • Mercurial is a distributed version control system similar to Git.
    • It emphasizes simplicity and ease of use.
    • It supports branching, merging, and a wide range of plugins.
    • Mercurial is known for its clean and intuitive command-line interface.
  2. Subversion (SVN):
    • Subversion is a centralized version control system.
    • Unlike Git and Mercurial, SVN relies on a central repository for version control.
    • It is known for its simplicity and ease of setup.
  3. Perforce (Helix Core):
    • Perforce is a centralized version control system designed for handling large codebases and binary assets.
    • It’s widely used in the gaming and media industries.
    • Perforce offers fine-grained access control and a robust branching system.
  4. Bazaar:
    • Bazaar is a distributed version control system that prioritizes ease of use and flexibility.
    • It’s designed for projects of all sizes, from small personal projects to large-scale collaborations.
    • Bazaar supports various workflows, including centralized and decentralized.
  5. Fossil:
    • Fossil is a distributed version control system that combines version control, bug tracking, and wiki features in a single tool.
    • It’s known for its simplicity and self-contained nature.
    • Fossil is suitable for smaller projects and single-user development.
  6. Darcs:
    • Darcs is a distributed version control system with a unique approach to handling changes.
    • It uses a concept called “patch theory” and allows easy merging and cherry-picking of changes.
    • Darcs is appreciated for its simplicity and elegant handling of branching and merging.
  7. Monotone:
    • Monotone is a distributed version control system that emphasizes security and cryptographic integrity.
    • It’s designed to provide strong guarantees against data corruption and tampering.
    • Monotone is suitable for projects where data integrity is critical.
  8. Concurrent Versions System (CVS):
    • CVS is one of the earliest version control systems and is centralized.
    • It has been largely replaced by more modern distributed and centralized VCS like Git and SVN but is still used in some legacy systems.

The choice of a version control tool depends on your project’s specific requirements, team preferences, and existing infrastructure. Git remains one of the most widely used and versatile version control systems, but these alternatives can be valuable in certain situations or for specific use cases.

Git Command Cheat Sheet

Git is a powerful version control system that can greatly improve your development workflow. By understanding its fundamental concepts and using the provided command cheat sheet, you’ll be well-equipped to manage your codebase effectively, collaborate seamlessly with others, and track your project’s history with ease. Mastering Git is a crucial skill for any developer, and with practice, you’ll become proficient in using it to your advantage. Happy coding!

 

Purpose Command Example Explanation

Configuration

Set user name git config --global user.name "Your Name" git config --global user.name "John Doe" Configure your name globally.
Set user email git config --global user.email "your.email@example.com" git config --global user.email "john.doe@example.com" Configure your email globally.

Creating a Repository

Initialize a repository git init git init Create a new Git repository in the current directory.
Clone a repository git clone <repository_url> git clone https://github.com/user/repo.git Clone an existing repository to your local machine.

Making Changes

Check status git status git status View the status of your working directory.
Stage changes git add <file_name> git add file.txt Add changes in <file_name> to the staging area.
Unstage changes git reset <file_name> git reset file.txt Unstage changes for <file_name> but retain modifications.
Commit changes git commit -m "Message" git commit -m "Add feature" Create a commit with a descriptive message.

Branching

Create a branch git branch <branch_name> git branch feature-branch Create a new branch with <branch_name>.
Switch to a branch git checkout <branch_name> git checkout feature-branch Switch to an existing branch by name.
Create & switch branch git checkout -b <new_branch_name> git checkout -b new-feature Create and switch to a new branch with <new_branch_name>.
List branches git branch git branch List all branches in the repository.

Merging

Merge branches git checkout <target_branch> <br> git merge <source_branch> git checkout main <br> git merge feature-branch Merge changes from <source_branch> into <target_branch>.

Resolve merge conflicts

Collaboration
Fetch changes git fetch git fetch Fetch changes from a remote repository.
Pull changes git pull git pull Pull and merge changes from the remote repository into the current branch.
Push changes git push git push Push local commits to the remote repository.
Push new branch git push -u origin <branch_name> git push -u origin new-feature Push a new branch to the remote repository.

History

View commit history git log git log Display a log of all commits in the current branch.
Show commit differences git diff <commit_id_1> <commit_id_2> git diff abc123 def456 View the differences between two commits.

Undoing Changes

Discard local changes git checkout -- <file_name> git checkout -- file.txt Discard local changes in <file_name>.
Undo last commit (soft) git reset HEAD~1 git reset HEAD~1 Undo the last commit, keeping changes in the working directory.
Undo last commit (hard) git reset --hard HEAD~1 git reset --hard HEAD~1 Undo the last commit, discarding all changes.

Use this cheat sheet as a quick reference to help you navigate Git with ease and efficiency during your development projects.

If you are looking for DevOps training in Kolkata for professional devops course in a low cost you must contact AEM Institute. This is the top devops certification training course which includes hands on lab and free examination preparation for AWS DevOps Engineer Professional Certification and Azure DevOps Engineer Certification.

 

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!
Scroll to Top