Tutorials

Working with GitHub

In this tutorial, you will learn about GitHub and how to perform the basics operations, synchronizing your source code between the local machine and online repository.

What is GitHub?

GitHub is an Internet code hosting platform for software development, version control, and collaboration using Git. It lets you and others work together on projects from anywhere.

Plus, it provides the distributed version control of Git, access control, bug tracking, software feature requests, task management, continuous integration, and wikis for every project.

How to set your project on GitHub?

First, you must create an account and sign in into:
https://github.com/

Next, Create new Repository. This will be your online project’s folder.

After that, you must create a local copy of your repository, copying that folder on your local machine.

For that, get the URL of you repository from your GitHub page, there should be a link with clone/download somewhere.

Next, open Git Bash command line, navigate to your local projects directory, and run the following command:

git clone [your-repository_url]

Provide credentials, when asked.

Now, your local project folder is connected to your GitHub online repository.

It’s time to get back to work.

How to interact with GitHub

You are working locally on your project, you have made some changes to the files inside its folder.

You must Stage and Commit your changes to the Git first.

In case you’ve missed this, please refer to our Git tutorial: [Control your projects with Git]

git commit -a -m "Added new functions to the code and more details to readme.md"

After that, you must update your remote repository on GitHub with your latest changes. Open Git Bash, navigate to your project’s folder and run the following command:

git push

Provide your credentials, and you’re done.

Note:
You can set an SSH key-pair on GitHub, so it recognizes your computer, so you will no longer need to type your username and password each time.

If you must update your local repository from GitHub, in case that someone from your team pushed updates to it, just use this command:

git pull

There is a lot more thing you could do with Git and GitHub, including branching and collaboration. For that, consult the official documentation.