nazaninsbr / Git-Commands

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Git: distributed version control system

Sources:
[1] This youtube tutorial
[2] Git Docs.


Basic Commands:

(1) get the version of git you have installed:

$ git --version

(2) set your name and email (this will be what others see in the author section):

$ git config --global user.name "my name"
$ git config --global user.email "myEmail@x.com"

(3) see git setting:

$ git config --list

(4) how to use help in git:

$ git help <what you need help with>
$ git <what you need help with> --help

(5) create a git project in the directory you are in:

$ git init

(6) see modified files:

$ git status

(7) add files to staging area:

$ git add --all
$ git add -A
$ git add fileName

(8) remove files from the staging area:

$ git reset fileName
$ git reset

(9) commit the files that are in the staging area:

$ git commit -m "something"

(10) see the commits:

$ git log

(11) set the remote repo:

$ git remote add origin <url>

(12) check the remote repo. url:

$ git remote -v

(13) see branches:

$ git branch -a

(14) see how the files have changed compared to the commited ones:

$ git diff

(15) get the changes on the remote:

$ git pull
$ git pull origin master

(16) push changes to remote:

$ git push -u origin master
$ git push 

(17) create a branch and go to it:

$ git branch <branch name>
$ git checkout <branch name>

(18) merge branch with master:

$ git checkout master
$ git merge <branch name>

(19) see merged branches:

$ git branch --merged

(20) delete branch:

$ git branch -d <branch name>

(21) delete branch on remote:

$ git push origin --delete <branch name>

(22) change remote url

git remote set-url origin <url>

(23) forget a file and remove what you had tracked of it

git rm --cached <file>