installing :  sudo apt-get install git

setting up: git config –global user.name “prashanthmadi” git config –global user.email “prashanthrmadi@gmail.com”

this will generate ~/.gitconfig file

initiallize git :

you can clone existing git project by using

  • git clone url

create  a new project by entering into a directory and enter

  • git init

to add files to git use

  • git add file1 file2

or else add all of them at once by

-> git commit -a // this will add all the files at once

-> git add . // not sure check this command

You are now ready to commit. You can see what is about to be committed using git diff$ git diff –cached

(Without –cached,  will show you any changes that you’ve made but not yet added to the index.) You can also get a brief summary of the situation with :

git statusignoring some files

get into top level of working directory and create file named .gitignore

foo.txt // to remove any file named as foo.txt *.html // to remove all files ending with html

**creating new branch**

  • git branch new_branch_name

to watch all the branches

  • git branch

to switch between branches

  • git checkout branch_name

merge two branches using merge option

  • git merge branch_name   // do this when u are in another branch

two people working on same project

A         —–   >            B

Scenario  1:

consider two users as above.  A has a git  and B wants to make changes to it.

  • B will clone the project using clone command
  • B will make required changes and commit them
  • B says A about his changes.
  • A will issue a pull command   as    git pull project_url_of_b

Scenario 2: (defining remote repository)


* git remote add new_user new_user_url

* git fetch 

this is a bit confusing update this scenario later.....
**To get only the changes from previously existing git**

* git pull URL

A general scenario of working with team happens as we release a public version in some repository. while we still work on current repository and someone else sends you changes
DEV-REPO --- > PUBLIC-REPO
PUBLIC_REPO --- downloaded by another person -- > DEV2-REPO
after some changes in DEV2-REPO
DEV2-REPO --- > PUBLIC2-REPO
PUBLIC2-REPO --- > DEV-REPO // merge

* git push public-repo master // to send into public repositories