Skip to main content

10 basic git commands you must know

If you work on software development project then you might have already used git for version control. If you haven't used git yet then it's high time you should learn and start using this. Following are the 10 git commands you must know while getting started with git.

1. git initIt initializes the git repository. Running this command creates a directory(.git) inside the current directory which contains git configuration and other repository data.  See below image how there was no git repository initially and after running git init, an empty git repository is initialized as we can see the .git directory gets created.

2. git status: It shows the current status of the repository by showing the difference between index file and the current HEAD commit. It shows the untracked files and files which are added to staging area but not yet committed. You can use different options with git status
Using -s option gives the output in short format.
Option -v or --verbose will show the changes which are staged to be committed.

3. git checkout: It is used for switching between branches.
git checkout <branchName> will switch to the branch. You can also create a new branch and then switch to it in one step by using the option -b. 
git checkout -b <branchName>creates a new branch and then switches to the newly created branch.

4. git add: It adds files to the staging area to be committed.
git add <file1> <file2> will add files "file1" and "file2" in the staging area. We can also use regular expressions to add multiple files at once.
git add *.txt will add all files with suffix .txt.
git add . will add all files present in the current working directory.

5. git commit: It commits all the changes which are in the staging area. Running the command git-commit will open the text editor for the commit message to write. Write useful commit message so that even other contributors to the repository should be able to figure out about the changes done in the particular commit.
git commit -m "commit message goes here": By using the option -m, you can directly provide the commit message in the same line without opening a separate editor.

git commit -a : It will add all changes to staging area then commit.
git commit -am "commit message": Adding all files and committing inline.

6. git diff: It shows the changes made since the last commit. To see the changes in the file which are added in the staging area, use git diff --cached

7. git log: It shows commit logs.

8. git branch: It helps in showing the current working branch.
git branch -d <branchName> can be used to delete the branch.

9. git stash: If you made some change in a branch but want to park those changes for a while and want to work on some different branch, git stash is your friend. It parks the uncommitted changes to a stash area. You can have multiple stashes.
git stash list: Shows the stack of stash. Latest on the top.
10. git push: After you have made all the changes and committed its time to push those changes to the remote branch. By using git pushthe current branch is pushed to the corresponding upstream branch, but as a safety measure, the push is aborted if the upstream branch does not have the same name as the local one.

This is a very basic version of the actual power of git commands showcased above and you can actually do much more by using different options. We haven't talked about merge, rebase, hooks & much more stuff. I will cover them in future posts and will try to cover each git command in more details.

Since you are still here at this post I am providing few best resource for learning git for beginners as well as seasoned programmers.

  1. : This is one of the best resources to start with if you are a novice. It is interactive and easy to start with. 
  2. : If you are already using git and want to dive deeper. 


Popular posts from this blog

Coin Flipping Puzzle: Interview Question

Golu has 100 identical coins (with head side and tail side) which he wants to donate to someone. There are many people who are aiming to get this collection of 100 coins. So Golu created a puzzle using all 100 coins and declared that the one who will solve his puzzle will get all the coins. You desperately need money so solving the puzzle is only option you have.

The Problem goes like this:
All 100 coins are laying flat on a table. 80 of them are heads up and remaining 20 are tails up. You can’t feel, see or in any other way find out which side is up. Split the coins into two piles(sets) such that there are the same number of tails in each pile.
[Baby Hint]: If number of coins in first pile is n then other pile will have 100-n coins.

First try yourself before peeking into the solution below. 

आ तमाशा तू भी देख

देखने वाले देखते हैं, सब कुछ देखते हैं ये लोग

देख देख कुछ करते नहीं, जाने कहाँ से लगा ये रोग । 
गरीब देखा, पीड़ित देखा, देखे उनके खेत बंजर

फर्क उनको कुछ पड़ा नहीं, देख किसानों का ये मंजर झूठ वादा, झूठे काम, किसानों के प्रति झूठा सम्मान सब देख मंद मुस्काते हैं, चाहे फांद गला लटके किसान हिन्दू देखा, मुस्लिम देखा, देखी जाने कितनी जाती पर जिससे इंसान दिखें, ऐसी कला कहाँ उनको आती देखने वाले देखते हैं, सब कुछ देखते हैं ये लोग देख देख कुछ करते नहीं, जाने कहाँ से लगा ये रोग । 
घर में देखा, ऑफिस में देखा, देखा ओलंपिक्स में परचम लहराते चाहे जितने हुनर उनके देखे, पर कसी फब्तियां आते जाते कल के दुश्मन आज हैं भाई, गले पड़े भुला के सब लफड़े लेकर ठेका आदर्शवाद का, नाप रहे दूजों के कपडे अधरों पे बेशर्मी का पर्दा, जो पीड़ित है उसी की गलती देख देख इन बड़बोलों को, दानवों की कमी कहाँ है खलती देखने वाले देखते हैं, सब कुछ देखते हैं ये लोग देख देख कुछ करते नहीं, जाने कहाँ से लगा ये रोग । 
सड़क नहीं, बिजली नहीं, जनता का पैसा, उनकी जेब जहाँ देखो वहीँ मिलेंगे, भरे पड़े मक्कार फरेब देखो जनता से इनका प्यार, पांच वर्ष म…


JSONJSON(JavaScript Object Notation) is a human-readable data exchange format. 
JSON is built on two structures: A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence. JSON's basic data types are: Number: a signed decimal number that may contain a fractional part and may use exponential E notation, but cannot include non-numbers such as NaN. The format makes no distinction between integer and floating-point. JavaScript uses a double-precision floating-point format for all its numeric values, but other languages implementing JSON may encode numbers differently.
String: a sequence of zero or more Unicode characters. Strings are delimited with double-quotation marks and support a backslash escaping syntax.
Boolean: either of the values true or false
Array: an ordered list of zero or m…

[Fixed] Alexa can count only from 1 to 10

Note: At the time of writing this post, Alexa had this issue which has been resolved. Alexa can now count flawlessley even in reverse.

Alexa is the smart virtual assistance by Amazon. It is beating google now and Siri on non-screen devices. Alexa is hailed for its intelligence but it seems that the Alexa knows to count only from 1 to 10. By 1 to 10, I mean exactly from 1 to 10; neither more nor less. Even asking Alexa to count from 1 to 5 or 3 to 10 or 3 to 5 results in an apology from Alexa. Watch the above video to see for yourself.

10 small business idea to start with in India

If you want to start your own business and you want to start small, here's are 10 business ideas which you can try. The following business takes less capital and more enthusiasm.

1. photography:

If you have a genuine interest in photography and want to make some money out of it then there are many opportunities may land your doorstep. It ney.eds more passion than anything else to start earning from photography. You can sell your photos to stock photography sites like,,, etc. You can also provide your photos to the online travel sites like There are many types of photography viz Architectural photography, Candid photography, Documentary photography, Fashion photography, Food photography, Landscape photography, Night-long exposure photography, Conceptual/ fine art photography, wedding photography etc.

2. Wedding Planner:

India is a place of the largest bunch of young people and wedding happens in large number eve…

Get access to everyone's Aadhaar data at Rs 500--A Tribune Report

Time and again UDAI(Unique Identification Authority of India) has been asserting that our Aadhaar data is secure and people of India can rest assured about the protection of our personal and biometric data. We have seen security flaws surfacing on the Internet over alleged data breach of Aadhaar and again Tribune has published about the existence of major security breach happening on daily basis. Our Aadhaar data, which is supposed to be highly secure in the hands of UIDAI is available to anyone who can pay Rs. 500.

According to Tribune, people are approached via WhatsApp for the service using which you are provided the portal and the username & password to use the portal. Using this service you can feed Aadhaar number and you will be able to download all personal details. This service is being provided at the mere amount of Rs. 500. Not only this, if you pay Rs. 300 more, you will be able to download the Aadhaar card also.

The government of India is trying to make Aadhaar the so…

BCCI fails to renew domain name for its official website is(or should I use "was") the BCCI's official website where it posts news about Indian cricket and even live-stream the cricket events. I tried to reach to their page and it's rendering above page as the domain has expired and BCCI(Board of Control for Cricket in India) has failed to renew it within the expiry deadline.

After using whois for this domain name, I got to know that the domain was registered on 2nd February 2006 and was updated again today on 4th February 2018.

Will BCCI be able to regain its domain back?

Update: BCCI has got its domain back and showing the contents as earlier.

कोई तो होता

भटकता जब मैं अपना पथ  भूल जाता लगाकर मैं गोता, वापस मुझको लाने वाला  काश ऐसा कोई तो होता। 
गिरकर, भटककर, खाकर चोट  जब मैं मन ही मन रोता,  मेरे दुखों को समझने वाला  काश ऐसा कोई तो होता। 
सन्नाटे के धुंध में जब  चुप चुप अकेले मैं सोता,  मुझसे बातें करने वाला काश ऐसा कोई तो होता। 
अनगिनत जिम्मेदारियां अपनी  होकर असहाय जब मैं ढोता, मुझको सहारा देने वाला  काश ऐसा कोई तो होता। 
जीवन के संघर्षों से लड़कर  जब मैं अपना मनोबल खोता, साहस मुझे बंधाने वाला  काश ऐसा कोई तो होता। 
खाकर अपने पीठ पे खंजर  जब मैं अपने जख्मों को धोता,  मरहम मुझको करने वाला

Brave Browser: A Faster, Safer and Rewarding Browser

There are tonnes of browsers in the market viz. Chrome, Chromium, Safari, Firefox, Edge to just name a few. Google Chrome enjoys the largest share of users among all Web browsers. Google Chrome is based on the Google backed open source project called Chromium. In recent years, we have experienced that more and more browsers are adopting the chromium platform. OverviewBrave is a free and open-source web browser developed by Brave Software, Inc. based on the Chromium web browser. It blocks ads and website trackers, and provides a way for users to send cryptocurrency contributions in the form of Basic Attention Tokens to websites and content creators.FeaturesFasterIt blocks network calls for trackers, ads and other monitoring scripts resulting in a safer and faster web browsing experience. It blocks ads from youtube and other web pages leading to faster load of the page and saves time when you are watching video on youtube.Safer It blocks all trackers and scriptsFeaturesYou can easily im…