DEV Community

Derrick TheCodeholic
Derrick TheCodeholic

Posted on

Introduction to GitHub day1

GitHub is a website and service that we hear geeks rave about all the time, yet a lot of people don’t really understand what it does. Want to know what all the GitHub hubbub is about? Read on to find out.
What is GitHub?

GitHub is a file or code-sharing service to collaborate with different people.

GitHub is a highly used software that is typically used for version control. It is highly used especially when more one person is participating in a project.
Advantages of using GitHub

  1. GitHub provides you a beautiful visual interface which helps you to track or manage your version controlled projects locally.
  2. Once you register on GitHub, you can connect with social network and build a strong profile.
  3. It makes it easy to contribute to your open source projects Now lets get started with GitHub..

How to create a GitHub account
To create a GitHub account visit GitHub Website and fill the sign up form then click on start a new project.project
Create a new repository

A repository is a storage space where your project lives. It can be local to a folder on your computer, or it can be a storage space on GitHub or another online host. You can keep code files, text files, images or any kind of a file in a repository. You need a GitHub repository when you have done some changes and are ready to be uploaded. This GitHub repository acts as your remote repository. So let me make your task easy, just follow these simple steps to create a GitHub repository.
repo
Fill the required details and click on create repository button.
This is how it looks once you create it
gittutorial
How to create a branch

Branching: Branches help you to work on different versions of a repository at one time. Let’s say you want to add a new feature (which is in the development phase), and you are afraid at the same time whether to make changes to your main project or not. This is where git branching comes to rescue. Branches allow you to move back and forth between the different states/versions of a project. In the above scenario, you can create a new branch and test the new feature without affecting the main branch. Once you are done with it, you can merge the changes from new branch to the main branch. Here the main branch is the master branch, which is there in your repository by default.
To create a branch in GitHub, click on main and fill the name of your branch. Am creating a branch called New-branch. Follow the screenshot below.
branch

GitHub commands.
1. Commit Command
This operation helps you to save the changes in your file. When you commit a file, you should always provide the message, just to keep in the mind the changes done by you. Though this message is not compulsory but it is always recommended so that it can differentiate the various versions or commits you have done so far to your repository. This is an example screenshot
commit
2. Pull Command
Pull command is the most important command in GitHub. It tell the changes done in the file and request other contributors to view it as well as merge it with the master branch. Once the commit is done, anyone can pull the file and can start a discussion over it. Once its all done, you can merge the file.
Click the ‘Pull requests’ tab, Click ‘New pull request’, Once you click on pull request, select the branch and click ‘readme- changes’ file to view changes between the two files present in our repository, Click “Create pull request”, Enter any title, description to your changes and click on “Create pull request”.
3. Merge Command

command which merge the changes into the main master branch. We saw the changes in pink and green color, now let’s merge the “readme- changes” file with the master branch/ read-me. Click on “Merge pull request” to merge the changes into master branch. Click “Confirm merge”.
4.Cloning and Forking GitHub Repository
Cloning a repository means that you're downloading a copy of the source code from source control. You can clone a repository from GitHub to your local computer to make it easier to fix merge conflicts, add or remove files, and push larger commits. When you clone a repository, you copy the repository from GitHub to your local machine. Above the list of files, click Code, you can clone the repository using HTTPS", SSH or GitHub CLI. You can then Open with GitHub Desktop or download zip. refer to screenshot below
clone
A fork is a copy of a repository. ##Forking## a repository allows you to freely experiment with changes without affecting the original project. Most commonly, forks are used to either propose changes to someone else's project or to use someone else's project as a starting point for your own idea. Go to Explore and search for public repositories. Click “fork”.

Top comments (0)