Getting Started with git


  • Setup
  • Create your first repository and push
  • Commit and push
  • Remote Origin
  • Branching
  • Logging and navigating history


Local configuration

Local configuration means that your attributes are applicable only within your repository. Configure your username and email using following commands,

git config --local "zillani"

git config --local ""

View: Verify if name and email are set using the following commands, this would print the configured username and email

git config --local

git config --local

Global configuration:

Local configuration means that these variable are applicable for all the git repos on your system by default.

git config --global "zillani"

git config --global ""

This could have also be set by editing .GITCONFIG file located in your root directory, Example for windows: C:\Users\lenovo


email =
name = zillani

Creating your first Repo and Pushing:

Imagine that you have an empty repository on, whose url is, now you have some basic template of your app that you want to push to server, here’s what you would need to do,

git init

git remote add origin ""

git add .

git commit -m "initial commit"

git push -f origin master

Note: origin is just a word, you can use any other word say stash-origin or any word

Commit and push

git add .

git commit -m "Added logger"

git push origin master

Remote Origin

git remote -v - Display remote origins

git remote remove origin - Deletes origin

git add remote origin - Adds Remote origin

[Note: origin is just a keyword, any other keyword can also be used]


View branch

git branch -l
git branch -r

Creating new branch

git checkout -b dev


Shift to existing other branch say from ‘master’ to ‘dev’

git checkout dev

Merging branches

Merging dev into master, checkout to master branch and

git merge dev

Deleting a branch

Locally, say deleting dev branch

git delete -d dev

Remote branch,

git push origin :dev

Logging and Navigating history

Check your logs

git log

Check your changes

git status

Navigate back to some old commit

use the SHA1 code of the log, using git log and copy some portion on the SHA1 of the commit and give as below

git checkout u8jedfy667h6359ah77
Getting Started with git

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s