19.08.2024

Action of GitHub Repository

Corporate services make it easier for teams to work together, increase productivity, and increase the convenience of working on projects. Git allows you to work together on a single project in a repository format with mechanisms for collaborative development and product version control. In this article we will look at how to create your own repositories in GitHub and upload data to it.

What is GitHub?

GitHub is a Git-based platform that allows you to run a full software development cycle, orchestrate and automate services, and store data. The difference from Git is that this system is derived from the main system and many architectural services are deployed around the repository version control system. Such as: database, web application, web server, caching server, message broker and many more.

It became popular due to the ability to host your own projects on public servers and the very concept of Git system allows the community to develop projects together using the convenient mechanisms of the service.

How to create a GitHub repository?

First, go to the official GitHub website and select the plus button on the top right to create a new repository:

Screenshot №1 — New repo

Fill in all fields with an asterisk and the rest as required by your project, then note that it is better to choose a short and memorable repository name for easier handling.

Screenshot №2 — Create GitHub repo

Also note that a repository can be public, i.e. available to all users of the Git platform, or it can be private. In this case, access is granted to selected users or teams. After that, click on the Create repository button and wait for the project to be created.

Now a repository has been created on the GitHub server and can be accessed from a client device via the git utility, install it beforehand:

dnf install git -y

Or for an apt-like distribution:

apt update && apt upgrade && apt install git -y

For Windows, use the command in terminal:

winget install git.git

Screenshot №3 — Install git

Navigate to the working directory with the files you want to upload and initialise the local repository in it, and prepare the files for sending with commands:

git init
git add .
git commit
git remote add origin git@github.com:login-of-user/name-of-repo.git
git push origin main

If you don't have sufficient resources than you can perform actions on powerful cloud servers. Serverspace provides isolated VPS / VDS servers for common and virtualize usage.

Screenshot №4 — Create Server

It will take some time to deploy server capacity. After that you can connect in any of the convenient ways.

If you have not added a public key, you will most likely see a Permission denied error, which means access is denied. You can familiarise yourself with authentication methods in our material, then come back to this one.

After the above steps, let's make sure that the repository has been created:

Screenshot №5 — GitHub repo

But, what if we need to make changes to it?

How do I manage files in a GitHub repository?

This can also be done with a simple command on the client, first make the necessary changes to the working directory or Working Tree. For example, let's create a new file with the command:

touch /gg/gg.txt

After that, register the changes to the index and create a commit by writing a confirmation with the phrase commit in the opened file, save it:

git add .
git commit

Note that the connection point for the repository doesn't need to be specified anymore, because it was specified earlier with the git remote add command. Now we access it via the origin variable:

  git push origin main

Screenshot №6 — Git push

As you have realised the working principle is that we modify the local copy first and then download the changes to the repository. Accordingly, to download changes from another user to the repository you can run the following command:

git pull

Screenshot №7 — Git pull

Working with GitHub and Git greatly simplifies project management and development. Using repositories, version control, and collaboration capabilities, development teams can efficiently share code, track changes, and integrate them into the overall project.

GitHub provides not only a place to store and share code, but also a wide range of tools for process automation, project management, and collaborative coding.