#1 git init
This git command will let you create a new repository. It can be used to convert an existing, un-versioned project to a Git repository or initialize a new, empty repository. This is usually the first command you'll run in a new project. But you can’t see the Init file in your project folder, it’s remained hidden.
Example:
$ git init
#2 git status
Example:
$ git status
#3 git add
Example:
$ git add <file-name>
or
git add .
#4 git branch:
This Git commands let’s us add a branch to an existing master branch , viewing all existing branches, and delete a branch. There’s already a master(main) branch in your project.
Example:
$ git branch <branch-name>
or
$ git branch a
$ git branch or git branch --list
or
$ git branch -d <branch-name>
or
$ git branch -m <branch-name><new-branch-name>
#5 git checkout
Example:
$ git checkout <branch-name>
or
$ git checkout -b <new-branch-name>
#6 git commit:
Every time you commit your code, you have to include a brief description of the change made. Before pushing to repository and after add the file to staging are this command is usually used. This commit message helps others understand the changes that have been done.
Example:
$ git commit -a
or
$ git commit -m “<Msg>”
or
$ git commit -am “<Msg>”
or
$ git commit –amend -m “<Msg>”
#6 git push:
This git command push the local file change to the remote repository. It also creates a branch automatically names as a Master branch if any branch doesn’t exist.
Example:
$ git push or $ git push <remote> <branch-name>
or
$ git push origin master.
#7 git pull:
This git command achieves the last uploaded changes from the remote server to the local repository to get the latest updates of the remote repository.
Example:
$ git pull or $ git pull origin master
#8 git merge:
This git command merges your created or added branches with the master branches. It lets you take the independent lines of development created by git branch and integrate them into a single branch.
Example:
$ git merge <branch-name>
#9 git diff:
This git command Show changes between commits, commit and working tree, etc. Mainly I used to see the either I forget to upload any changes to repository.
Example:
$ git diff --staged
#10 git reset:
Git reset is a powerful command that is used to undo local changes to the state of a Git repo. It will undo the last change you have done on git repo.
Example:
$ git reset hard
#11 git log:
Git log command shows a list of all the commits made to a repository.
Example:
$ git log
or
$ git log --oneline
#12 git clone:
Git log command shows a list of all the commits made to a repository.

Comments
Post a Comment