DEV Community

Cover image for Introduction to Git & GitHub
Pratik Kale
Pratik Kale

Posted on • Edited on

Introduction to Git & GitHub

Hello Folks,
Welcome to my Git & GitHub blog series. I'll be going through from basic to advanced level. I'll be also exploring the GitHub Student Developer Pack and the tools which can be helpfull for you.
So stay tuned for upcoming blogs!

Git and GitHub are powerful tools that have revolutionized the way developers work on projects. In this blog post, we'll provide an introduction to Git and GitHub, explain what they are and how they work, and demonstrate some basic Git commands and concepts with examples.

Sample Git Terminal

What is Git?

Git is a distributed version control system that allows developers to keep track of changes to code over time. It was created by Linus Torvalds in 2005 as a tool to help manage the development of the Linux kernel. Since then, it has become one of the most widely used version control systems in the world.

Git works by creating a local repository on your machine that contains all the code for your project. You can make changes to the code, and Git will keep track of those changes in a series of "commits". Each commit represents a snapshot of your code at a particular point in time, along with a message describing the changes you made.

GitHub

What is GitHub?

GitHub is a web-based hosting service for Git repositories. It was created in 2008 and has since become the most popular Git hosting service in the world. GitHub provides a number of features that make it easy for developers to collaborate on projects, such as pull requests, issues, and wikis.

GitHub also provides a number of additional tools and services, such as GitHub Pages (a tool for hosting static websites), GitHub Actions (a tool for automating workflows), and the GitHub Student Developer Pack (which provides a variety of free tools and services to students).

Basic Git Concepts and Commands

Here are a few basic Git concepts and commands to get you started:

Cloning a Repository

To clone a Git repository, you'll need to use the git clone command followed by the URL of the repository you want to clone. For example, if you wanted to clone the official Git repository, you would run the following command:

git clone https://github.com/git/git.git
Enter fullscreen mode Exit fullscreen mode

Creating a New Branch

In Git, a branch is a separate line of development that allows you to work on a feature or bug fix without affecting the main codebase. To create a new branch, you'll use the git branch command followed by the name of the new branch. For example, to create a new branch called "my-feature", you would run the following command:

git branch my-feature
Enter fullscreen mode Exit fullscreen mode

Switching to a Branch

To switch to a different branch in Git, you'll use the git checkout command followed by the name of the branch you want to switch to. For example, to switch to the "my-feature" branch that we created earlier, you would run the following command:

git checkout my-feature
Enter fullscreen mode Exit fullscreen mode

Making a Commit

To make a commit in Git, you'll use the git commit command followed by a message describing the changes you made. For example, if you made some changes to a file called "index.html", you would run the following commands:

git add index.html
git commit -m "Updated index.html with new content"
Enter fullscreen mode Exit fullscreen mode

Pushing Changes to GitHub

To push your changes to a GitHub repository, you'll use the git push command followed by the name of the remote repository and the name of the branch you want to push to. For example, if you wanted to push your changes to the "my-feature" branch of a repository called "my-repo", you would run the following command:

git push my-repo my-feature
Enter fullscreen mode Exit fullscreen mode

Conclusion

This was just a brief introduction about Git & GitHub. In the upcoming I'll be writing about setting up Git on your local machine.

Thank you for reading and do let me know your thoughts in comments!

Connect With Me :



Website | Twitter | Instagram | Mail

Top comments (1)

Collapse
 
dnyanada02 profile image
dnyanada

Quite helpful for beginners.