DEV Community

Cover image for Git and Github
viola kinya kithinji
viola kinya kithinji

Posted on

Git and Github

What is Git? It is a version control system that you download onto your computer. It is essential that you use Git if you want to collaborate with other developers on a coding project or work on your own project.

What is version control? The management of changes to documents, computers programs, large websites, and other collections of information.

Terms used.

-Directory-folder.
-Terminal/command line-interface for text commands.
-CLI-commandline interface.
-Cd-change directory.
-Code editor-word processor for writing codes.
-Repository-project, or the folder/place where your project is kept.
-Github-A website to host your repositories online.

Git Commands.

-clone-Bring a repo that is hosted somewhere like Github into a folder on your local machine.
add-Track your files and changes in Git.
-commit-saves your files in Git.
-push-Upload Git commit to a remote repo, like Github.
-pull-Downloads changes from a remote repo to your local machine,the opposite of push.

Let's get started.

You will first start by downloading Git here https://git-scm.com/downloads. After downloading and setting up you will create a Github account here https://github.com/. Bingo! you have done it.

How to create a repo.

Image description


From the conversation box on the image you can see some commands there you will select new repository or on the left there is an icon indicating new.

Image description

On the above picture is an indication of how it will look like.

How to clone your repo to your local machine.
[](
Image description
The picture above shows how to copy the link so as to clone. On the icon labelled "code" below is the link copy it.

Cloning.

Image description
This picture shows how to clone it on your local machine.

How to add, commit and push.

Image description This picture shows how to track and saves my files in Git.

Git push.

Image description .Upload Git commit to a remote repo, like Github.

Pull Request.

Image description.A pull request (or PR) is a way to alert a repo's owners that you want to make some changes to their code. It allows them to review the code and make sure it looks good before putting your changes on the primary branch. .
Merging pull request.

Image description
You might see a big green button at the bottom that says 'Merge pull request'. Clicking this means you'll merge your changes into the primary branch. When you successfully merge the pull request make sure you delete your branch too many branches is a put off by doing so make sure yours commits were merged.

How it will look like after merging

Image description When you're done,You can double check that your commits were merged by clicking on the 'Commits' link on the first page of your new repo.

Image description. When you're done, you can double check that your commits were merged by clicking on the 'Commits' link on the first page of your new repo.

Image description This image shows a list of commits in your branch.

How to update the changes on Github to the repo on my local machine.
After creating a pull request and merging pull request on your github repo a little differences comes in with the one in your local machine. In order to get the most recent changes that you or others have merged on GitHub, use the git pull origin master command on your Git bash "git pull" This shows you all the files that have changed and how they've changed.

Conculsions.
The more you use git, the more comfortable you'll... git with it. (I couldn't resist.).Github is useful because you're able to store your code online and allows you and others to work together on projects from anywhere.

Latest comments (0)