Git is an open-source version control system and a command-line tool, it is used by programmers, developers, and designers to store projects and keep track of changes to their files. is a website where developers can store their projects. Some basic git command is mentioned below:

git clone /path/to/repository

This command is used to clone the application in local repository. Create a working copy of a
local repository.

git init

Create a new local repository.

git add

This command used to Add all the files to staging.

git commit -m “Commit message”

Commit changes to head (but not yet to the remote repository).

git config –global “jyoti” / git config –global “”

Configure the user name and email address to be used with your commits.

git remote -v

List all the currently configured remote repositories

git push origin

Send the committed changes to the branch of your remote repository.

git status

List the files you have changed and those you still need to add or commit.

git remote add origin

If you have not connected to your local repository to a remote server, add the server to be able to push the code.

git remote -v

List all currently configured remote repositories.

git checkout

Switch from one branch to another.

git checkout -b

Create a new branch and switch to it.

git branch

List all the branches in your repository, and also tell you on which branch you are currently in.

git branch -d

Delete the feature branch.

git push –all origin

Push all branches to your remote repository.

git pull

Fetch and merge changes on the remote server to your working directory.

git merge

To merge a different branch into your active branch.

git diff

Preview changes in all the files whatever you have done.

git diff –base

Preview changes for a specific file done by you.

git add

After you have manually resolved any conflicts, you can mark the changed file then pushed.

git log

Display all the commits with commitId that is pushed to the remote server, and CommitId will be unique for every commit.

git checkout —

With this command, we can undo local changes for that specific file.

git stash

Suppose you want to switch to another branch but you don’t want to commit what you have been working on yet, then you can stash the changes using above command.

git stash apply

You can reapply the changes to any branch that you have stashed by using the above command.

git stash clear

You can clear the stash using the above command.

git diff > patch_name.patch

This command used to create a patch with diff output (all the changes that you have done for all the files)

git diff patch_name.patch

Create a patch for a specific file.

git apply patch_name.patch

This command used to apply the patch file changes in your current branch.

git cherry-pick

Cherry picking is used to choose a commit from one branch and apply it onto another.

git reset –soft HEAD~1

Undo the last commit.

git reset –soft

Undo any previous commit.

git clean

Remove untracked files from the working branch.

git clean -f -d

This command used to remove directories, untracked files from the working branch.

git reflog

Manages reflog information means it keep a record of when the tips of branches and other references were updated in the local repository.




Ruby on Rails Development Company

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

What happens when you type ls -l in the shell

Cash pulled from popular BTecs in move to T-levels

Evolution of Microservices

BvB Miners Open test!

Windows: Error: listen EACCES: permission denied{{PORT}}

People can now get contact info cut from Google search results

Uncover the B-Side helpful Pandas functions

Vim/Neovim: Scripting using Python

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Ruby on Rails Development Company

More from Medium

How To Add Unit Tests To Your C# Project Using MSTest & Visual Studio

Vulnerabilities due to XML files processing: XXE in C# applications in theory and in practice

A Guide on how to install Git on your MacBook

Shadow DOM in .NET Selenium

C# logo and Selenium logo with shadow effect