Saturday, December 2, 2023

Few Useful Git Commands with Example for Beginners

     Git is a distributed version control system (DVCS) that is widely used for tracking changes in source code during software development. It was created by Linus Torvalds in 2005 to manage the development of the Linux kernel, but it has since become the de facto standard for version control in the software development industry.

Let’s dive into some Git commands,

git config

Usage: git config --global user.name “[name]”
Usage: git config --global user.email “[email address]”

This command sets the author name and email address respectively to be used with your commits.

git init

Usage: git init 

    This command is used to start a new repository in the current working directory.


git add

Usage: git add [file]

    This command adds one or more files to the staging area.

Usage: git add * or git add .

    This command adds one or more to the staging area.

git commit

Usage: git commit -m "[ Type in the commit message]"

    This command records or snapshots the file permanently in the version history.

git status

Usage: git status

    The git status command displays the current state of the local repository, including any changes that you’ve staged for a commit.


git branch

    The git branch command is used to create and manage branches. Git branches are separate copies of your main codebase that you can change without disturbing the main code. Your main branch is the one you initialized using git init.

Usages: 

list the all active branches. 

git branch

creates a new branch.

git branch <branch_name>

delete the feature branch.

git branch -d [branch name]







No comments:

Post a Comment