Friday, August 7, 2020

The Complete Guide to GitHub

The Complete Guide to GitHub © Shutterstock.com | 360bIn this article, you will learn about 1) an introduction to GitHub, 2) understand what GIT is, and 3) then experience a deep-dive on GitHub.INTRODUCTION TO GITHUBIf you are a programmer or have friends who are programmers, chances are you have heard of GitHub. GitHub is unlike almost any other website on the Internet. The Internet is raving about it and certain venture capitalists are pouring $100 million investments into it. But what is GitHub?GitHub is a web-based hosting service for all things Git. It is a repository for users to upload their projects to. It is a great place for developers to store all of their projects and access other users’ projects. Its applications include web hosting service and social media network.GitHub was founded in 2008 by Tom Preston-Werner, Chris Wanstrath and PJ Hyett. Since its launch, it has gained over 9 million users and 21.1 million repositories. With these numbers, GitHub has become the largest online host of source code on the Internet. It hosts users from all over the world and from all programming backgrounds.The great thing about GitHub is that it is for anyone. The biggest and boldest technology companies in the world upload projects to GitHub. It is one of the rare opportunities a person has to rub elbows with programmers and developers at companies like Google, Facebook and IBM. Despite its elite clientele, GitHub is by no means a secret or elite society. Any programmer with a working knowledge of Git can sign up and use GitHub.When you upload a project onto GitHub, other members can view your project. This is great because it means that everyone on the site can learn from one another’s successes and failures in programming. If you a struggling with a particular program, chances are, someone on GitHub can show you just how to fix it.One of the most appealing things about GitHub is that it is a complementary tool to social media sites like LinkedIn. While LinkedIn requires users to com plete full profile and add a resume, GitHub gives programmers a chance to demonstrate their real competencies. A GitHub hosted project has translated into more than a few job offers. HR managers looking for new engineers admit that if a candidate does not have a GitHub profile, they virtually do not exist.GitHub also launched an education project in 2014 that was designed to give students free access to a whole host of development resources.BASICS OF GIT1) Understanding GitGit is an open source, version control software / system developed by Linus Torvalds (of Linux).What is Git and what can it do?Git is an open source software. This means that users can change and share this free software. Although the software is open source, the use of “Git” and the logos are trademarked.Git is also a version control system. A version control system keeps track of all of the revisions made to a source code. It also stores each of these revisions in a repository. This kind of system both encou rages and enhances collaboration between developers. It allows users to download software, add their own changes and then upload their newly changed version of the software.Short history of GitThe development of Git began in 2005 when several developers at Linux suffered a breakdown in communication and goals with their source control management. Until then Bitkeeper maintained a free status that was in line with the goals and values of the Linux system. When Bitkeeper decided to begin charging for its services, the Linux team decided to move elsewhere.Linus Torvalds needed a new system of source control management that would fulfil the gap left by Bitkeeper. None of the systems available at the time met the needs of the goals of his software.Unimpressed by the current offerings, Torvalds began work on Git in April of 2005. The developers had specific goals for their new system. They knew that they could create a system that could not only fulfill the gap left by Bitkeeper but impro ve on the service.With a focus on speed, non-linear development and simple design, the developers worked quickly on Git. They were hosting the project only three days after the official announcement.Git basicsThe logic behind Git promotes non-linear development above all. By promoting non-linear development, the software promotes sharing and collaborating. Instead of organizing its data as a set of files that are changed over time, Git organizes its data as though it is a series of snapshots. Instead of simply noting changes, Git takes a picture of what the file looks like every time it is changed. This allows you to see what has changed faster than searching through files.Creating local operations was a huge priority for the developers of Git. As a result, Git is incredibly fast.2) Learning GitYou can use GitHub without knowing Git, but it is better for productivity and analysis if you have an understanding of it. Here are some key features that you need to know to begin to underst anding and making basic functions with Git:Command Line:The Command Line on Git is the place where you can access and run all commands on Git. While you do not need to know the whole command line for simple tools, it is helpful because it will teach you how to do more with your software.To use the Command Line in Git, you need to know how to use the Command Prompt function in Windows or Terminal in Apple.Whether you use Windows or Mac, you will need to know how to use text-based commands on the screen as opposed to using your mouse.Version Control:Version control is at the heart of Git. What version control means is that the software saves a picture of every change that you make to the program or the file.This is different to a traditional save method because in other programs you will have to overwrite a current file or safe a different file every time you make a change. Git simplifies this so that you do not ever lose any of your work.Repository:A repository is the space where you store your projects. It is similar to storing your documents or photos on the cloud with Google or Microsoft.A repository is also at the heart of what Git was created to do. You can store your work on a local fil on your computer or you can upload it to GitHub, the most popular online repository for Git projects.Getting started with Git means that you will either need to start a new repository or clone an existing repository.Commit:When people talk about committing in Git, they are talking about the command that works to take the picture that helps make version control work.This command works to take the picture of the repository so that you can go back to it at any point in time.Branch:Branch is another key part of Git. When there are several people working on the same project at the same time, they can “branch off” the main project. The branch includes a full version of the original project and each user can make their own changes with it.After the changes have been made, the y can merge their own branch back with the main copy of the project to make sure that everything flows smoothly.Fork:In principle, creating a fork is similar to creating a branch. When you create a fork off of a project, you are adding onto someone else’s project.Instead of working as a collaborator on a project you’re actively involved in, you can create a fork of another project to make contributions to the project without changing any of the main features of the project.If you have noticed or solved a problem on another project, you offer a Pull Request to offer your changes to the owner of the original project.The forking option is what takes GitHub from being a simple repository into a fully-fledged social collaboration tool. When users can actively contribute to projects that fit their skillset, more problems get solved in less time.Workflows: Workflows, or GitHub Flow, is a different kind of workflow than many people are used to. This kind of workflow is light and it is b ranch-based. It is designed to help projects that need regular updates move along smoothly.3) Git Specific commandsThere are several Git specific commands that are used on almost every project. The following commands are specific to Git and are some of the most basic but essential commands included in the program.git help: git help allows you to find any of the most common git commands that are used in the software. This is a very helpful tool because there are 21 common commands and remembering them all is not easy when you are first starting out. If you can only remember one command when you are starting you, you should make it git help.git init: The first command that you will need is git init because this is the command you use to start a new repository on GitHub. When you use this command, you turn a folder into an accessible repository. You need to use this command first. Without it, you cannot issue any other git commandsgit add: The name is confusing because it does not allo w you to bring new files into the repository. What git add does is draw new files to Git’s attention so that it can take snapshots for the repository.git status: This is a useful tool to use when you are mid project because it allows you to see what is happening within your repository. You can see which files you have included in the repository and you can also see recent changes that have not been committed to the main project.git commit: This is one of the most essential commands because it tells the software to make a snapshot of your repository.git merge: If you are working on a branch on GitHub, you use the git merge command to add the changes from your branch to the master copy of the program.git push: This function is used if you are working with a local file and want to include the changes you’ve made locally to the repository in GitHub.git pull: This function is similar to git push. You use git pull to grab the changes made to your online repository on GitHub and bring them to your local files on your computer.git checkout: This lets you look inside a repository without you having to enter the repository itself. Using this command, you can either view the master branch or any of the other public branches of the project.GITHUB1) GitHub: The Improved GitNow that you know a little bit more about Git, the benefits of GitHub will start to make more sense. Git is a programming language but it does not reach its full potential unless it is used in GitHub, which was specially built for users to make the most of its features.The biggest benefit of GitHub is that you can manage projects both locally and online.The ability to work online and offline and still see a fluid workflow on a project is what draws many developers to GitHub.You still have the ability to work from a local file. It takes only two simple commands to either download recent changes from the Internet or to upload changes you made to the local file.The web interface of GitHub makes the expe rience collaborative.Instead of sending files back and forth or updating them on the cloud, you can work fluidly and simultaneously with other people online.While other programs offer online collaboration, this often results in a slow user experience. Since GitHub allows collaborators to branch out from the main project, there aren’t several people working on the same branch of the project at the same time. This keeps it efficient and keeps the software moving quickly.The web experience also takes the collaborative experience further.Users on GitHub have access to the projects of everyone online. This makes GitHub an invaluable tool for both novice and experienced programmers.New programmers can look at the methods used by advanced programmers and learn new techniques or solutions to their own problems. It also allows users to learn from the mistakes of other projects.The online interface also allows other people to view your projects and correct your mistakes. So if you’re deal ing with an issue and a programmer happens to know how to solve it, they can fork off of your project, solve the problem and you can see the snapshot of how to fix the issue.The best part about the service is that there is never any data lost. GitHub records every single change so you can see everything that has happened in your project. It also prevents anyone from doing any damage to the project. You can pinpoint just where the issue begins and wipe it out from the source.2) Getting Started with GitHubGetting your projects online with GitHub is relatively easy. All you need to do is sign up, install the software and get started on a new project.Account SetupThe first thing that you will do when you are getting started with GitHub is sign up for an account online.You will need to provide a valid email address and a password. You will also need to choose a unique user name.There are a large number of people who search GitHub looking for new talent. While a silly user name will not p ut recruiters off genius engineering, it is important to choose a serious and inoffensive name to better your chances of being discovered.After you have entered these three fields, you will click the Sign up for GitHub button.You will then be prompted to choose a price plan or an upgraded package. This is not mandatory for individual users. This is mostly aimed at companies who want to keep some of their projects on GitHub’s private site where other people cannot see them.Remember that you have full functionality of GitHub on its free plan so there are no added benefits in signing up for a paid membership unless you have a project that needs to be kept private.After you are signed up, you just need to click the logo on the top-left of your browser. This will navigate you to your personal dashboard.After you have signed up, you can complete a profileYour avatar and other details are not required for you to use GitHub but they do make your profile look more complete.You should set u p the extra two-factor authentication offered by GitHub. This will help keep your work safe should your password be stolen.You also need to confirm your email address with GitHub. GitHub organizes your projects according to the email address you submit them with.If you commit your projects using different email address, ensure that you have all relevant email addresses added to your profile. This will keep everything organized.After you have an account, you can either create a new project or clone an existing projectCreating a new project requires you to create a repository.To create a repository, you need to go to https://github.com/new and then create a new repository using the command git init.The git init command will create a new repository for you. It can also convert an existing project into a new repository.You must use this command to begin using almost every other command on git.You can also clone your work.If you already have an existing Git repository, you can clone it i nto a new repository. To do this, you will enter the git clone command.This clone will operate as a working copy for the original repository. It will operate in a different environment from the original and neither project will reflect changes made to the other one.Once you are all set up, you can begin to make changes to your project.To make the first change, you will use the git add command. From here, you can begin to make changes to the project.The git add command will not add changes to the repository on its own. You must also include the git commit command to record the changes.3) Hosting Making Changes to Your Website on GitHubAny website needs a host. A host is a server that stays running 24 hours a day to keep your website online. Unless you have the need and means to have your own server, you will need to find yourself a host.GitHub lets you host your website on their site for free. When you host with GitHub, you also have total control of your site which is an added bene fit of using their service.Hosting your site is probably one of the most complicated parts of getting started on GitHub but only if you want to choose a domain name to associate with.After you have registered and set up a new repository in GitHub, follow these steps for setting up a website:The first thing you need to do is to create your repository because the files that are included in your website need to be stored in oneIf the website you are creating is going to focus on a project that already exists, you just need to add a new branch to the repository to host the website files.After you have a repository, you need to create what is called an orphan branch. You should title this branch gh-pages. All of the website files will be hosted in the orphan branch and should be deleted from the main branch of the repository.After you have set up your orphan branch, you can add your website files to the branch. You will use the git add command to add the pages. Make sure that you remembe r to use the git commit command to submit the changes to the project.After this, you need to push the changes you have made back to GitHub itself. All you need to do is use the git push command. Once you have pushed the changes online, you will be able to find your project at http://yourusername.github.io/respoistoryname/If you want to create a professional website, you will need to purchase a domain name. Once you have purchased the domain, you can associate it with your GitHub page. You have to create a subdomain, specifically an apex domain. There are four main steps that you need to take to add a custom domain to your website:You must begin by opening the website’s folder locally.You need to create a new file called CNAME in the local folder. You can use a text editor and enter the domain name you have purchased without the www.Then you must enter the following commands: git add; git commit â€" m ‘CNAME add’; git push origin masterAfter you have done this, you will need to edit your domain name settings (DNS). How you do this will depend on the company you purchased the domain name from.CONCLUSIONThis article serves as a basic guide for getting started on GitHub. Once you have set up an account and learned the basic commands, it is easy to get your projects online.GitHub is a great place to work on Git projects for many reasons. Whether you are working on a group project as a part of a degree program or you are working on a collaborative program in a professional environment, GitHub is the perfect software to use for group work.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.