0 votes
in DevOps by
What are basic Git commands.?

1 Answer

0 votes
by

Some of the Basic Git Commands are summarized in the below table -

Command

Purpose

git init

Used to start a new repository.

git config -

git config –global user.name “[name]”

git config –global user.email “[email address]”

This helps to set the username and email to whom the commits belong to.

git clone <repository path>

Used to create a local copy of an existing repository.

git add -

git add <file names separated by commas>

git add .

Used to add one or more files to the staging area.

git commit -

git commit -a 

git commit -m “<add commit message>”

Creates a snapshot or records of the file(s) that are in the staging area.

git diff -

git diff [first branch] [second branch]

git diff -staged

Used to show differences between the two mentioned branches/differences made in the files in the staging area vs current version.

git status

Lists out all the files that are to be committed.

git rm <file name(s)>

Used to delete a file(s) from the current working directory and also stages it.

git show <commit>

Shows the content changes and metadata of the mentioned commit.

git branch -

git branch [branch name]

git branch -d [branch name]

git branch

The first one creates a brand new branch.

The second is used to delete the mentioned branch.

The last one lists out all the branches available and also highlights the branch we are in currently.

Related questions

+1 vote
asked Aug 23, 2021 in DevOps by sharadyadav1986
0 votes
asked Mar 26, 2021 in Git by rajeshsharma
...