What is git ?

GIT / Future Techno India

Basic commands of GIT

git config

git init

Creates/initializes a new Git repository. It is the first command you need to know if you want your project to be under revision control.

git clone

Copies a Git repository. The most common method for developers to get a working copy of a central repository is by cloning.

git add

Changes are moved from the working directory to the staging area. As a result, you can prepare a snapshot before committing it to the official history.

git commit

Commits the staged snapshot to the project history. Together with git add, this defines the basic workflow for all Git users.

git status

This displays the state of the working directory and the staged snapshot. To see what’s included in the next snapshot, you’ll also want to run git add and git commit.

git show

It is used to view expanded details about Git objects such as blobs, trees, tags, and commits. Each object type has its own behavior. Tags show additional objects that are associated with the tag. In a tree, names and content of objects are displayed.

git log

Provides access to previous revisions of a project. Provides a variety of formatting options for displaying committed snapshots.

git branch

You can use this command to perform general branch administration tasks. This command allows you to create isolated development environments within one repository.

git checkout

Besides allowing you to check out old commits and file revisions, git checkout also allows you to navigate existing branches. Combined with the basic Git commands, it provides a way to work on a particular line of development.

git merge

Merging is Git’s way of putting a forked history back together again. You can merge the independent lines of development created by git branch by using the git merge command.

git diff

This command shows the file differences which are not yet staged.

git clean

This is builtin command to cleanup the untracked files. Be careful with this one, it deletes files permanently!

  • If you just clean untracked files, run git clean -f
  • If you want to also remove directories, run git clean -f -d
  • If you just want to remove ignored files, run git clean -f -X
  • If you want to remove ignored as well as non-ignored files, run git clean -f -x

git rm

This command deletes the file from your working directory and stages the deletion.

git remote

This command is used to connect your local repository to the remote server.

git pull

This command fetches and merges changes on the remote server to your working directory.

--

--

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