As a web designer, or developer you know the importance of keeping your projects organized and well-maintained. But what happens when you need to manage multiple versions of your project, collaborate with other developers, or ensure that your hard work is safe and secure?
That's where Git and GitHub come in. Git is a powerful version control system that allows you to track changes to your project and collaborate with others. And GitHub is a web-based platform that makes it easy to share your code with others and work on projects together.
In this article, I will guide you through the basics of Git and GitHub, including the benefits of version control, how to create a repository, & commit changes. Whether you're a seasoned developer or just starting out, Git and GitHub can help you manage your projects with ease and peace of mind.
So, if you've ever worried about losing your hard work due to system crashes or hardware failure, DON'T WORRY. Git & GitHub got you covered.
Before we know about GIT & GITHUB, we should first be familiar with the term version control.
What is version control?
It's also known as source control, which helps track and manage changes to software code. It keeps track of every modification of codes and stores it in an advanced database. Even if we make mistakes, we can refer to an earlier version of the code to fix them.
Importance of Version Control system
Most of the time, software products develop through teamwork by a group of developers. They might be at different locations, but the version control system helps the developer team to efficiently interact and manage all the software codes with information like who made the contribution and what updates have been made.
It also has a branch system, where a separate branch is created for every member who can make some changes that changes don't merge with the original source code until the changes have been analyzed. Otherwise, it would be a mess to work as a team if all member of the group makes their changes in the same source code. It won't be possible to track who made which changes because the source will get overwritten every time.
Before we move forward there is something I would to like add here.
Beginners often wonder "What's the difference between Git and GitHub?". And if you are one of them, then let me break it to you their differences.
Ready to learn Git and GitHub?
What is Git?
Git is the most widely used modern distributed version control system today. It was developed by Linus Benedict Torvalds. Many software projects rely on Git for version control, including commercial and open source. Git has the advantage of branching capabilities. Git branches are easy to merge. Each developer gets their local personal repository with a history of all commits.
What is GitHub?
GitHub is a code hosting platform for version control and collaboration. It allows you to share your local git repositories online as an open source where anybody has a look at them. We can say it's an online social media platform for software developers where people across the globe can work together as a team or share their insights. GitHub also provides private hosting services for personal projects.
Okay! If you have done with the theories, the question may arise in your mind. "how do we push our local git repositories on GitHub?" Let's see about that.
Your first repository on GitHub
Before you begin, you will need a GitHub account. So step zero would be to Go to github.com and enter the required user credentials for the SignUp and create your account.
Step 1. Once you have created your account you will see a green button that says ''Create repository'' click on the button.
Give the repository a name you want and again hit the button "Create repository".
Step2. Install Git on your computer from here. (only window users need to do this step)
Step 3. After installing Git. you need to configure it in your terminal (you can do that in your vs-code terminal) as shown below in the image.
Write down the below code in the terminal and remember to use the same username and email address as you use while creating a GitHub account.
git config --global user.name "yourusername"
git config --global user.email "youremailaddress"
Step 4. Type the following command lines in the terminal:
Initialize a git repository.
git init
To add the files to the Repository.
git add <Filename> // git add .
git add .
it is used to add all files.To create a commit.
git commit -m "....message..."
This command line saves the changes with a specific message. In a double inverted comma, you can write any message for reference.
To create a new branch.
git branch -M main
This command line is used to create a branch. By default, it creates the main branch named master.
The repository URL is given by GitHub.
git remote add origin (repository URL)
URL is provided by GitHub of your repository.
To push files to GitHub.
git push -u origin main
It will push your file to your new repository.
Remember these steps are for the first time pushing files to GitHub Repository. You don't have to repeat all these steps when you want to update your files.
Now, suppose you are making some changes in an already existing file or you want to add a new file to your GitHub repository. The only steps you will need to follow are:
git add <filename>
git commit -m "....message..."
git push
and press enter.
There are so many other git command lines for different purposes. You should check it out from the below resources:
Outro:
Git & GitHub are vital tools for efficient and secure project management, allowing you to track changes, manage versions, & collaborate with others. GitHub enables the hosting & sharing of repositories with the world. By mastering these tools, you can enhance your skills whether you're a beginner or experienced. Don't hesitate to start exploring the benefits of version control with Git and GitHub.
If you found this article helpful & are interested in learning more about web development, I highly recommend checking out my article series on HTML, CSS, and JavaScript.
In my HTML series, you will learn the fundamentals of creating web pages & how to structure content using HTML tags. You can access the HTML article series by following these links:
In my CSS series, you will discover the power of styling and how to use CSS to make your web pages visually appealing. You can access the CSS article series by following these links:
And in my JavaScript series, you will explore the world of dynamic web development and learn how to add interactivity to your web pages. You can access the JavaScript article series by following these links:
6 Fundamentals of JavaScript:
There is more....
ππHappy coding!ππ
Thanks for taking the time to read this article. I hope this was helpful to you.ππ