Working with Git on the command line can be little bit tricky. To help with that, I’ve listed common Git commands in this article, what each one means, and how to use them. My aim is to make Git easier to use on a daily basis.

git config

This "git config" command helps you to, Tell Git who you are by allowing you to configure the author name and email address to be used with your commits.
1
2
git config --global user.name "John Doe"
git config --global user.email "[email protected]"

git init

This command helps you to Create a new local repository or initialise existing project.
1
git init

git clone

This command helps you to create a local working copy of an existing remote repository, this command uses to copy and download the repository to a computer. It is the equivalent of git init when working with a remote repository. Git will create a directory locally with all files and repository history.
1
git clone https://github.com/dinushchathurya/MEAN-to-do-app.git

git add

This command uses to Add one or more files to staging (index):
  • To stage a specific file:
    1
    git add index.html
  • To stage an entire directory:
    1
    git add css
  • To add all files not staged:
    1
    git add .
  • git commit

    This command records the changes made to the files to a local repository. For easy reference, each commit has a unique ID you can include a message with each commit explaining the changes made in a commit. This commit message helps you to find a particular change or understanding the changes.
    1
    git commit -m "<commit message>"

    git push

    This command uses to send local commits to the remote repository. It requires two parameters: the remote repository and the branch that the push is for.
    1
    git push <remote_URL/remote_name> <branch>

    git status

    git status command returns the current state of the repository. git status will return the results related to current working branch. It shows the files in the staging area, but not committed. Or, if there are no changes it’ll return nothing to commit, working directory clean.
    1
    git status

    git branch

    To determine what branch the local repository is on, add a new branch, or delete a branch.
  • Create a new branch
    1
    git branch <branch name>
  • List all remote or local branches
    1
    git branch -a
  • Delete a branch
    1
    git branch -d <branch name>
  • git cheackout

    Imagine that you have different brach in your project,to start working in a different branch, use git checkout to switch among branches.
  • Checkout an existing branch
    1
    git checkout <branch name>
  • Checkout and create a new branch
    1
    git checkout -b <new branch name>
  • git pull

    git pull To get the latest version of a repository run git pull. This pulls the changes from the remote repository to the local computer.
    1
    git pull <branch_name> <remote_URL/remote_name>