Beginners Hands-On With Git: The Most Awaited!

Lets track our first project via git & how to actually use git ?

Β·

5 min read

Beginners Hands-On With Git: The Most Awaited!

Hello Folks, Welcome To The Fourth Blog Post From The Series Of Git & GitHub. As Promised I Will Deliver The Comprehensive Series On Git & GitHub, let us Get into the fourth part without any delay!

Prerequisite For this blog : (Follow The Order, As Provided!)

πŸ‘‰Version Control System

πŸ‘‰Git & GitHub: Introduction

πŸ‘‰Git Installation

πŸ‘‰Git Three-Stage Architecture

If You Have Already Read the Above Ones, Then Continue With This Blog Post. In this blog post, we'll be doing some basic hands-on so that you can get a real feel of how to actually get started with the Version Control!

So, The Time Has Came Up..... Let's git init! πŸš€

⚠️ DISCLAIMER: Ensure That You Have installed git on your system... If you haven't, Click Here to know how to install it, or go via this link git-scm.com

⚑Showtime: Let's Go!

Getting started with Git and GitHub involves a few steps, including installation, repository initialization, committing changes, and pushing code to GitHub. Here's a step-by-step guide with examples of commands:

πŸš€ Pushing On To The Remote From Local:

1. Install Git:

  • As Stated Above, Visit the official Git website (git-scm.com) and download the installer for your operating system.

  • Run the installer and follow the instructions to complete the installation.

2.Configure Git:

  • Open a terminal or command prompt or git bash(recommended) which you will get upon the successful installation of git.

  • Set your name using the following command:

    git config --global user.name "Your Name"

  • Set your email address using the following command:

    git config --global user.email "youremail@example.com"

3. Initialize a local Git repository:

But Going Through This Process, Let us first understand what does this repository mean ?

So, A repository, often called a "repo" for short, is basically like a folder or a directory that contains all the files, folders, and version history of a project. It's a central place where you can store and organize your project's code, documentation, and any other related files.

Imagine you're working on a group project where multiple people need to collaborate and make changes to the project's files. Instead of sharing files back and forth through email or other means, you can create a repository to centralize everything.

In a repository, you can keep track of changes made to files over time. This allows you to see who made the changes, what changes were made, and even revert back to previous versions if needed. This version control aspect is one of the key benefits of using a repository.

Repositories also enable collaboration among team members. Different individuals can work on separate branches of the repository, making their changes independently. Then, these branches can be merged together to combine the changes and resolve any conflicts that may arise.

Moreover, repositories are often connected to platforms like GitHub, GitLab, or Bitbucket, which provide additional features and services. These platforms allow you to host your repository online, making it accessible to others, and facilitating collaboration, code reviews, issue tracking, and more.

In summary, a repository is a place where you store and manage all the files and versions of a project. It simplifies collaboration, keeps track of changes, and provides a central location for everyone involved in the project to work together.

Now, Let Us See, how to initialize a git repository:

⚑Create a new directory for your project :

πŸ‘‰mkdir project1

πŸ‘‰cd project1

⚑Initialize a new Git repository :

πŸ‘‰ git init

⚑Create and modify files:

πŸ“Œ Create a new file or make changes to existing files in your project directory.

⚑Add files to the staging area :

πŸ“Œ Add specific files to the staging area (along with the extensions):

πŸ‘‰ git add <file-Name1> <file-Name2>

πŸ“Œ Add all modified and new files to the staging area:

πŸ‘‰ git add .

⚑Commit changes :

πŸ“Œ Commit the changes to your local repository :

πŸ‘‰ git commit -m "Your Message"

⚑Create a repository on GitHub :

πŸ“Œ Go to github.com and sign in or create a new account.

πŸ“Œ Click on the New button to create a new repository.

πŸ“Œ Give your repository a name, optionally add a description and choose other settings.

πŸ“Œ Click on the "Create repository" button.

⚑Connect your local repository to the remote repository :

πŸ“Œ Copy the URL of your remote repository from the GitHub repository page.

πŸ“Œ Add the remote repository URL to your local repository:

πŸ‘‰ git remote add origin <remote_repository_url>

⚑Finally Push your code to GitHub :

πŸ‘‰ git push -u origin master

After completing these steps, your code will be uploaded to your GitHub repository. You can continue making changes, committing them, and pushing them to GitHub as needed.

These steps provide a basic overview of Git and GitHub usage. There are many more advanced features and commands to explore as you become more comfortable with Git.

We'll be witnessing other advanced functionalities & commands in the upcoming blogs and will dive deep to see what git & GitHub has to offer more, so in the meantime congratulate yourself first as now you know how to use git and you have successfully pushed your first project on to the githubπŸŽ‰πŸŽŠ

With That Set, let us End Up Here!, I hope that I was able to add some knowledge and value in your learnings through this blog!
Still Doubtful ?πŸ€”πŸ€·β€β™‚οΈ Comments are always open. I will be Glad to help!

πŸ‘‰This is Part 4 Of The Series Of Git & GitHub, Stay Tuned For the Next Blogs!

πŸ‘‰Do Consider Subscribing to The Newsletter, so that you never miss an update from us!

#git #github #vcs #LearningInPublic

#HappyLearningFolks!

Did you find this article valuable?

Support Prakhar Sinha by becoming a sponsor. Any amount is appreciated!

Β