Useful GIT commands

Here are the list of major git commands and their short descriptions.

git init

    Initializes a git repository – creates the initial ‘.git’ directory in a new or for an existing project.

git config

    Configure git with username,  password, email-id, and server details. It can be configured --global / --system / --local

git clone

    Download a copy of project from GIT server (Eg: git clone

git add

    Add the files to local repository. Eg: git add file.txt / git add . - remove all changed files.

git rm

    Remove files from local repository. Eg: git rm file.txt / git rm . - remove all changed files.

git commit

    Save the added files to local repository, creates a new commit object pointing to it and sets the branch to point to that        new commit. Eg: git commit -m ‘committing added changes’ git commit -a -m ‘committing all changes, equals to git add      and git commit’

git status

    Show the current status of changes. Changed not add/commited/push to local.

git branch

    Show the list of local branches. In the output it will highlight the current active branch.

git push

    Push the commited changes from local repository to GIT server. Need to authenticate using username/password if it's       a private.

git checkout

    Switch for one branch to another. need to mention the branch name. Eg: git branch

git pull

    Fetches the files from the remote repository and merges it with your local one. This command is equal to the git fetch        and the git merge sequence. Example: git pull origin.

git diff

    Generates patch files or statistics of differences between paths or files in your git repository, or your index or your              working directory. Example: git diff

Tags: GIT Commands, GIT