Basics to Git and Github

Basics to Git and Github

·

4 min read

I recently learnt about Git and Github so thought why not share my learnings?

This Blog contains some of the basic fundamentals explaining Git and Github

1. Explaining a Ten year old what is Git: 🤓

👉Git is kind of book keeping mechanism which record the changes about who made changes,when made changes and what changes were made!

👉So if code is broken then you go back to previous one as computer are flawless but humans are not

👉Git is the change tracking mechanism

2. What is Repository? 🤓

👉All your source file in one folder or programming content at one place!

Things to note: 🤓

According to your changes in code note down the following:

👉Green color is for added

👉Red color is for removed

👉+ is file added

3. All about commit : 🤓

👉What is commit?

This is like commiting something. So when you made changes to code, you commit it writing a commit message about the change you made! Just like you change and save it

👉Know about some Good commit messages!

feat - a new feature
fix - a bug fix
docs - changes in documentation
style - everything related to styling
refactor - code changes that neither fixes a bug or adds a feature
test - everything related to testing
chore - updating build tasks, package manager configs, etc

Some examples to understand it better:

What would you put as a commit message if:

Q. You added some details to the readme file?

A. DOCS: added readme file

Q. Your CLI app was taking "potato" as an input for leap year test?

A. FIX: validating input for leap year

Q. You started using CHALK library in your CLI app?

A. STYLE: used chalk to beautify

Q. You added level based game play in your CLI app?

A. FEAT: added levels

Q. You renamed your variables from var a to var questions?

A. REFACTOR: changed variable name

4. Github: 🤓

👉Repository till now is only on your local machine but Github is something you put it on the cloud,other people can see it,consume it,collaborate it,enhance it thats how open source works So,difference between Git and Github in very simple terms is: Git is something doing on local machine but github is you put it on cloud and everyone can see it

5. Pushing the code: 🤓

👉Once you are done with commit message,All you need to do is pushing it to your branch on github.

6. Domain name 🤓

👉Any website name is itself the domain name

7. Server 🤓

👉Name Server: You give me the name,I will give you the address

something which keeps every domain name mapping to its corresponding server address

👉Server which serves the file...like take neog.camp? take it and go away

8. Hosting 🤓

👉Hosting means keeping the file on the server

👉To give something to someone,We have to first host it

9. Client 🤓

👉Client: Your browser,laptop,mobile browser which is trying to get something from the browser

10. Hosting the website online 🤓

👉There are many of the sources on which you can host the website but netlify.app is the top recommended.

11. Main Branch and other than main Branch🤓

👉Lets understand it with simple example:

👉You are driving a car on national highway. Now you notice your fuel is low so you take divergence and go to fill the fuel and come back to same main road.

Now understand:

👉There is one master/main branch.You create another branch,do some changes on that,try something new and then happy with the change. Now you merge it to master/main branch

So branch is the divergence to implement a new feature and then merging it to the main trunk

👉Note them until you do not merge it to the main branch,on the online hosted wbsite,you will not be able to see the changes of different branch. You can only see what is in the main branch online.

12. Pull Request(PR) 🤓

👉You can compare and pull request if you want to add it to main branch.

👉Once created the pull request you can also see the preview of how it will look after merging it to main. So on industry level when you are working as a team,this helps a lot

13. Pull and push 🤓

👉Server to client is pull

👉Client to server is push

I hope so far you are introduced to these basics and can apply now to make your presence on Github.

If you liked my content, How about connecting with me?

twitter

Github

Â