Learn Git & GitHub

Learn Git & GitHub

Learn Git and GitHub from experts ๐Ÿ˜Ž

ยท

4 min read

Git & GitHub is A Version Control for beginners and experts

Git and GitHub are two technologies that every developer should learn, irrespective of their field.

If you're a beginner developer, you might think that these two terms mean the same thing โ€“ but they're different.

Prerequisites In order to complete this tutorial, you'll need the following:

  • A Command Interface like cmd
  • A Text Editor of your choice (I Will use Visual Studio Code)
  • A GitHub account.

What is Git ?

What is Git? Git is a version control system which lets you track changes you make to your files over time. With Git, you can revert to various states of your files (like a time traveling machine). You can also make a copy of your file, make changes to that copy, and then merge these changes to the original copy.

For example, you could be working on a website's landing page and discover that you do not like the navigation bar. But at the same time, you might not want to start altering its components because it might get worse.

With Git, you can create an identical copy of that file and play around with the navigation bar. Then, when you are satisfied with your changes, you can merge the copy to the original file.

You are not limited to using Git just for source code files โ€“ you can also use it to keep track of text files or even images. This means that Git is not just for developers โ€“ anyone can find it helpful.

Installing Git

In order to use Git, you have to install it on your computer. To do this, you can download the latest version on the official website. You can download for your operating system from the options given.

You can also install Git using the command line, but since the commands vary with each operating system, we'll focus on the more general approach.

Configure Git

I will assume that at this point you have installed Git. To verify this, you can run this command on the command line: git --version. This shows you the current version installed on you PC.

Login To GitHub

If you have The Account before, Go to this Section

  1. Go to GitHub Official Site

image.png

  1. Write Your Information โ„น

image.png

Congrats Your GitHub Account Created Successfully ๐ŸŽ‰

Login To Git

The next thing you'll need to do is to set your username and email address. Git will use this information to identify who made specific changes to files.

To set your username, type and execute these commands: git config --global user.name "YOUR_USERNAME" and git config --global user.email "YOUR_EMAIL". Just make sure to replace "YOUR_USERNAME" and "YOUR_EMAIL" with the values you choose.

Initialize Your First Project

We are finally done with installing and setting up Git. It is now time to create our project.

  1. Create A Folder for Your Project
  2. Go to the bar in the top and write cmd โœ:

Screenshot 2022-01-29 131002.jpg

  1. A Window will opened like this:

image.png

  1. Write in this command prompt git init to Initialize New Git Repository:

image.png

  1. New Folder in Your Project Created Called .git

Now Create Your Files in your project

If you want to Create A Website create all files like index.html, Images Folder, style.css(main.css), Main.js and etc...

Publish Your Repository on GitHub

If you don't have an account in GitHub Go to this section

  1. You can click on the + symbol on the top right corner of the page then choose "New repository".

Screenshot 2022-01-29 131901.jpg

  1. Give your repo a name then scroll down and click on "Create repository".

Screenshot 2022-01-29 131927.jpg

  1. Give the repository name Don't Choice anything click on Create Repository

  2. Let's Copy This Commands and paste it in our command line:

image.png

  1. Go to the command line and commit our files
  2. Write in the command line git add .
  3. Write in the command line git commit -m "Git Tutorial"
  4. Write in the command line git push

Now go to Your Repository and refresh it Now your files you are push it Successfully pushed and Your Code in the web

Now if you want to host your site in github go and see this video

Thank you for reading ๐Ÿ“– ๐Ÿ˜๐Ÿ˜

Twitter Instagram Tweet A thanks GitHub

Subscribe to our newsletter

Read articles from Programming School directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Did you find this article valuable?

Support Programming School by becoming a sponsor. Any amount is appreciated!

 

Article Series

Web Developer

Practice to master