Earlier in the articles, we looked at how to install, configure, and work with the local Git repository. And in this article, we recall how to upload files to a remote repository and the main functionality and features when working in a GitHub account.
Keeping a project and tracking changes to files on GitHub is very convenient. Since GitHub has an intuitive interface and many features to fulfill your needs.
Let's start by registering on GitHub. We follow the link https://github.com/, click on ‘Sign up’ and go through the registration.
After registration, let's move on to creating and configuring the repository. Click on the ‘+’ icon and in the open window select ‘New repository’ to create a new repository.
Fill in the field and add the configuration to the repository.
Note: Up to 5 collaborators can use a private repository for free. Next, you need to pay according to the price, depending on the tariff plan.
You can also check the box “Initialize this repository with a README” to create a readme.md file. The readme.md file often contains general information about the project, environmental requirements, what needs to be done before installation, how to install, project creators, documentation, links, and much more. This file is executed in Markdown markup language (you can get acquainted with the syntax of the language on the GitHub page - https://guides.github.com/features/mastering-markdown/).
Let's move on to examining how to upload files to a remote repository.
If you have not yet connected a remote repository, then do this with the command:
git remote add test2 URL
where test2 is the name of your repository,
URL - The URL of your repository.
To view all connected repositories use the command:
git remote -v
As you can see from the screenshot, the test2 repository was successfully added.
To connect, you can use HTTPS and SSH protocols. You can find these fields by following these steps: click on the icon with your profile - Your repositories - and select the desired repository. In the open window, go to ‘Clone or dowland’ and simply copy the link from the field: either HTTPS or SSH access, respectively. As you understand by name, this link can also be used for other purposes, for example, to clone a repository.
We select the necessary protocol, to use SSH you need to generate and add SSH keys, how to do this you can find in our article ‘Generating and adding an SSH key to connect to a remote GitHub repository’.
Now you are ready to add files to the remote repository. As an example, we will transfer the files of this local repository to GitHub.
To do this, use the command:
We go to GitHub and see that all of our files have successfully moved.
The first column in the screenshot above is the name of the files themselves (by clicking on them you can see and change the contents of the file), the second column is the commits that were made on these files, clicking on them you can see a detailed description of the changes (what was added, what was deleted) in the file, and the third column shows when the last changes were made.
If you are running your project on GitHub, then you have the current current version of your project at hand. Well, of course, if it comes to Hosting, it is better to store your data in more than one place and always have backups. At any hosting plan, we make backups of files and databases every day. With HyperHost you can be sure that your project is in good hands.