Basics GIT  Commands

Basics GIT Commands

Table of contents

No heading

No headings in the article.

  1. Repository Creation
  2. Repository Observation
  3. Branches
  4. Changes
  5. Push, Reset, and Status
  6. Pull
  7. Help
  1. Repository Creation To create a new local repository from start :
$ git init

To clone an existing repository :

$ git clone your_url
  1. Repository Observation Shows new or modified files not yet committed :
$ git status

Shows the changes made to files :

$ git diff
  1. Branches List all local branches :
$ git branch

List all local and remote branches :

$ git branch -av

To merge branch_a into branch_b :

$ git checkout branch_b
$ git merge branch_a

To tag the current commit :

$ git tag <my-tag>
  1. Changes To stage the file ready for commit :
$ git add <file-name>

To stage all changed files ready for commit :

$ git add

To commit all staged files to versioned history :

$ git commit - m <message>

To commit all tracked files to versioned history :

$ git commit - am <message>

To show full changed history :

$ git log
  1. Push, Reset, and Status To push local changes to remote repo :
$ git push

To push all of the tags to the remote repo :

$ git push --tags <repo-name>

To unstage a staged file :

$ git reset <file-name>

To reset everything to the last commit :

$ git reset --hard HEAD

To get the current status of the repository :

$ git status
  1. Pull To get the latest changes from the remote repo
$ git fetch

To get the latest changes from the remote repo and merge

$ git pull
  1. Help To get help
$ git help