DEV Community

SIVAGANESH L
SIVAGANESH L

Posted on

Basic Git commands for beginners

I want to share what i have learnt so for from git. Git is version control system which helps us to track changes in our code and shared among the team members. It's really a great tool.

Here are some Basic commands that i have learned with simple words.

  1. git init
    It creates a new git repository, .git a hidden file will be created in the project folder and git starts to track everything.

  2. git status
    Shows the current state of your files and any time we can see what's going on

  3. git add
    Changes to include in the next commit and can be used before commit changes.
    To add specific file:
    git add filename.txt

To add everything:
git add .

  1. git commit command used to saves the changes after you add the your changes

git commit -m "Latest changes in home page"

  1. git log Show the history if commits

git log

  1. git branch shows all the branches or create a new branch

List out the branches:
git branch

Create a Branch:
git branch newfeature

  1. git checkout Command will switch between branches

git checkout newfeature

  1. git merge Command will merge or combine one branch to another branch and used when a newfeature is ready and you want add it to the main or master branch.

git checkout master
git merge new-feature

  1. git clone
    Command will copy remote repository to local machine and its used when multiple person work on same project.
    git clone https://github.com/

  2. git push
    Command will upload the changes into remote repository and its used after committing the changes locally.

git push origin main

  1. git pull Command will get the latest changes from the remote repository and its used before starting your work so that you are upto date .

git pull origin main

These are the basics git command.

Top comments (2)

Collapse
 
payilagam_135383b867ea296 profile image
Payilagam

Good start on git! Nice work

Collapse
 
pumpkin1996 profile image
SIVAGANESH L

Thank You. Will Try to create post regularly

Some comments may only be visible to logged-in visitors. Sign in to view all comments.