Git and Github
Tags: beginners, git, github
Published: 2021-07-25 18:25:52

Github launched in 2008, and became very popular because of its saas (software as a service ), providing a cloud based hosting service. But it is in fact git, that powers it. Below I'll explain Git and  Github.

###Git:
Git is a version control system. What that means is that it tracks and manages changes to the software code.

#### Git is newer:
There are a few version control systems out there, and an advantage that git has over them is that it is a newer, more modern implementation of version control. It is fast, because it is lightweight, so it runs quick.

#### Git provides team development, and a history of content changes:
Another advantage that git has is that it provides a history of content changes that happen, and it allows for team based collaborative development to take place. So all the people collaborating have access to not only the code that is being shared, but a history of changes that have been made, or will be made.

#### How collaborative development takes place:
The way in which git helps collaborative development is by taking a trunk based approach to development. So what happens is that a developer gets a copy of code, makes changes, and then merges it back into the main file. I'll explain this while defining terms below:

>**Repository:** Your project folder. This would contain all your project files.
**Branch:** A version of the repository that diverges from the main project repository.
**Clone:** Make a copy of the repository.
**Fork:** Make a copy of the repository on Github.
**Commit:** We open code from our copy of the repository, and if we like changes to our code, we commit the changes to our copy of the repository.
**Push:** Transfer code from our copy of the repository to the original project folder.
**Pull and merge:**  Since multiple users are working on the repository, another user might have pushed code into the main repository, and the code might have updated in the main repository. So once a developer completes their changes, they get the code or pull it from the main project repository, and merges it with their own code.
**Merge conflict:** The developer has modified the same code as another developer who has already pushed their code into the main repository. So the developer works with the code, and makes changes accordingly.
**Pull request**: Once conflicts are resolved. The developer puts a pull request that notifies every member that changes need to be reviewed.
**Approve pull request:** The main repository owner approves the pull request.
**Merge:** The main repository owner now merges the code into the main branch.

So a developer clones the main repository. A branch gets created where the developer works on their copy of the repository. Edits are made by the developer and they commit the changes to their copy of the repository. They pull, and merge the code from the main repository to their own repository. If there is a merge conflict, these are resolved. A pull request is sent to notify members that changes need to be reviewed. Once everything looks good. These changes are approved and merged with the original project folder.

###Github:
While using git, the main repository files of a project are stored on a local or a cloud network, and files are accessed and modified using command line on a computer.

Github took this implementation of git, and provided a cloud service, where the files were stored, and the files could be accessed and modified. This would mean that people could see, access and make changes to files using GitHub. Since command line is not required, this also made it very easy for people not that familiar with coding to have access to the progress of a project. GitHub provides open source projects, which also made people have access to a huge directory of projects to clone or as GitHub calls it fork them.

The following actions can be done in GitHub to create, clone, commit, pull, merge, and push a repository:
>Below we used the account boywithabeard(the one in dark theme) to create the main repository, and bigdig to clone the repository (the one in light theme).

#####Create a repository:
Go to the home page, and then click on the green new button on the top left side:
![Screen Shot 2021-07-25 at 12.56.42 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bg7rmx69kha6s5dn88dv.png)
Enter a repository name, in this tutorial we have named it: Tutorial, and then click on create repository:
![Screen Shot 2021-07-25 at 12.58.25 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dbyq53373mk4pooj5ufx.png)
####Clone(Fork) a repository:
Go to a repository. On the top left side you would find the word fork. Click on it, and you would get your own copy:!
![Screen Shot 2021-07-25 at 1.27.21 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fhfxmzaugr2nrz8kc4rz.png)

####Commit:
Open any file, in this example we opened the file named .gitignore, in our copy of the repository:
![Screen Shot 2021-07-25 at 1.33.00 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1izipu3njlfkhyua9ksp.png)
 
Once the file is open, click on the edit pen icon:
![Screen Shot 2021-07-25 at 1.33.24 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/78cy7fidw7y8q2frppst.png)
 
Make some changes, in this example we added the line, `just for a tutorial`:
![Screen Shot 2021-07-25 at 1.36.21 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1rmw3dsb8o2c4npla2ky.png)
 
Add details about the changes you made, and press on commit changes:
![Screen Shot 2021-07-25 at 1.34.44 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/20ri8lcdzr3ddbtcqn1x.png)
 
####Pull request:
Go to your repository, and click on the tab pull request, then click on new pull request:
![Screen Shot 2021-07-25 at 1.35.12 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aj6ju8wplxtggri5czlt.png)
 
Now click on create pull request:
![Screen Shot 2021-07-25 at 1.36.21 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ngesci53mih7jemuesw3.png)
 
 
Add details about the changes you made, and press on create pull request:
![Screen Shot 2021-07-25 at 1.35.42 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kog3fa78by0i3gteb8hk.png)

You can click on your pull request in your repository. Now you and the main repository owner, can add comments and discuss the issue:
![Screen Shot 2021-07-25 at 1.42.05 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqit7eg91ij8z85zqgu8.png)
![Screen Shot 2021-07-25 at 1.40.14 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f5jj0l031df2u5h8bcvo.png)
![Screen Shot 2021-07-25 at 1.40.49 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h7mrqp1vwnud6dfvedvx.png)
![Screen Shot 2021-07-25 at 1.41.19 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0l86ht52dqa9wf0kerok.png)

####Pull and merge::
The parent, boywithabeard, creates a merge pull request, to notify everyone about the changes:
![Screen Shot 2021-07-25 at 1.43.19 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/epvxvpaq71cif3tyr04e.png)

####Merge:
If there are no disagreements, he or she then merges the code:
![Screen Shot 2021-07-25 at 1.43.27 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c74mjnwui61uamcuf7am.png)
  
 
Check out the video where I go over the concepts mentioned above: 
[Youtube Video](https://youtu.be/FgqvBUkWMVw)