DEV Community


git - part 1: for Beginners

sayamahi profile image Mahipal Originally published at Updated on ・3 min read

Hey, do you remember about Safety Net that I mentioned here. Ya, Git falls under this classification, its Source Code Control.

More like version control.

Git - is a version control software tool.

Github - is a Repository. Mainly used for code/projects.

(just like Google Drive - is a repository of all your documents/pictures/other files).

lets say

  • Today, you write 10 lines of code - lets call that version-1.
  • Tomorrow, you edit 2 lines and add 5 more lines of code - now its version-2.
  • Later, You/Someone else, will add/update another few lines of code - now its version-3.

Now you want to go back to version-1 (or any other version) - Sure thing. possible with Version Control Software/Tool. Finally We Don't need to create folders each day to say Day1_code, Day2_Code,...

Maybe you must have seen this in google docs (also similar in Microsoft docs)

You see , there are different versions of the above document and so different features in your google drive. Similarly in Git, there are different features and commands for those features.

  • you can create a document.

    In Git, you say `git Init`

  • daily add some content to it,

    In Git, you say `git add .`

  • you can name each version.

    In Git, you say `git commit -m `Earth Topic`

Lets say Yesterday you wrote about Mars, name that version Mars and Today you wrote about Earth, so name that version as Earth, that will be easier for you to switch to previous date/version or to identify all the versions.

  • google docs has Auto Save. Or you manually Click Save. In Git, you say `git push`
  • move(restore) document to any of the previous date,

    In Git, you say `git checkout [branch-name]`

  • You/(like many others) can get access (collaborate) to other peoples google drive documents, and your can update the your changes to the original document

    In Git, this is called pull request

  • and you can get latest updated document and see all the new changes.

    In Git, this is called `git pull

In Git, there are many other features, and many other technical terms to know of.

If you do not have a github account, create one.

and Now you can do 2 things.

  • work on your own project, and upload/maintain your code in your github account. > use git commands
  • work on others project i.e, collaborate, or use others project and make changes and run it independently based on its licence, from your github account. > use fork, clone and git commands

If you go into others repositories, (this is your origin repository) you can see fork and clone

Usual steps when you Fork or Clone


fork clone
click on fork use git clone command
1. downloads a copy to your github account 1. downloads a copy to your local machine
2. clone the repository to your local machine -
3. make changes on your machine 2. make changes on your machine
4. push changes to your github repo 3. push changes to your github repo
5. send Pull Request Command to send changes to Original repo -
6. If original repo Owner accepts your changes, your code will be merged -

I will write another post on some of the commands and about the work flow.

If you liked the content, please free to follow me on twitter

Part 2 of the post is here

Discussion (0)

Editor guide