Skip to main content

Command Palette

Search for a command to run...

Git for Beginners: A Comprehensive Guide

Updated
2 min readView as Markdown
Git for Beginners: A Comprehensive Guide
J

I am excited to continue my learning journey in DevOps. I believe that DevOps is the future of software development, and I am excited to be a part of the movement.

Git is a distributed version control system (DVCS) for tracking changes in any set of files. It is designed to handle very large projects with lots of contributors. Git is used by many open-source projects, including the Linux kernel, the Ruby on Rails framework, and the Android operating system.

Git commands are used to manage a Git repository. They can be used to create, add, commit, diff, checkout, merge, push, pull, and reset files and branches in a repository.

Here are some of the most commonly used Git commands:

  • git init: Creates a new Git repository.

      git init
    
  • git clone: Clones an existing Git repository to your local machine.

      git clone https://github.com/Jatinkc/git-repo
    
  • git add: Adds files to the staging area.

      git add file.txt
      git add . #adds all the files in the directory to the staging area
    
  • git commit: Commits the changes in the staging area to the repository.

      git commit -m "added file.txt"
    
  • git diff: Shows the differences between the working directory and the staging area, or between two commits.

      git diff file.txt
    
  • git checkout: Checks out a specific commit, branch, or tag.

      git checkout mybranch
    
  • git merge: Merges two branches together.

      git merge mybranch
    
  • git push: Pushes changes from your local repository to a remote repository.

      git push origin
    
  • git pull: Pulls changes from a remote repository to your local repository.

      git pull
    
  • git reset: Resets the working directory to a specific commit, branch, or tag.

      git reset 9a9add8
    

9a9add8 indicates a commit id used to revert back discarding all the changes after that commit

  1. Learn Git Branching

More from this blog

Jatin Chourasia

49 posts

Goes by the name LegionDev