gitHub, gitLab and bitBucket are some of the most popular web-based hosting services in our Git repository. They have a web-based graphical interface with all the benefits of the git tool and clients for desktop and mobile. Simply put, services like gitHub, GitLab, and bitBucket are a great place to share your code with friends, colleagues, classmates, and even complete strangers. This does not mean that if you use these hosting services, others will know everything about you. Such a public repository can be opened here. In the same way, if you want to protect the privacy of your code, you can open a private (unlimited or limited number of free) repository. Many open-source projects continue to work with their huge community using these hosting services (gitHub, GitLab, and bitBucket). They do not require an account for anyone to read the public repository’s code, and the entire repository can be cloned to one’s own PC with the click of a mouse. You usually need an account to open a repository in these then you can open public or (unlimited or limited number of free for a small amount of money) private repository. You can put code of many projects in these hosting services. You can put the code of one of your projects in a repository. One of the advantages of these hosting services is that the code you type in them can be seen by anyone around the world. Anyone can develop the source code of your application. Since it is an online storage system, you can access it from anywhere and commit to change the code.
Connecting the Git Repository to gitHub:
Now we will connect our Git Repository to one of our GitHub accounts. And for this, you must first have an account on GitHub. Hopefully, you can do this job on your own very easily.
Once the account is created, you need to login to your GitHub account. After login, you will see a plus sign on the top right. Clicking there will open a menu where you will see the text New Repository. Clicking here will take you to the page to create a new repo.
Then first give the owner and name of your repository here. Remember that repository names should be unique and URL friendly. And since the description field is optional, you can give something if you want and you can leave it blank. But it is better to write about repositories in detail than to leave them blank. In the next field, select whether you want to make it a public repository or a private one. However, if you have a free account, you will only have access to the public repository. Now leave the rest of the fields as they are and click on the Create repository button.
Now with the click of the Create Repository button, a new repository will be created in your GitHub.
Now we will see how to connect to our already created Git repository with our created GitHub or push Repository there.
Push on GitHub:
We have to be sure of a few things before pushing to GitHub. That means you have to make sure you have everything committed. Also, need to check if you are in the master branch? You can easily check it with the git status command.
If all goes well, now you need to clone the new repository created in your GitHub as below.
Once cloned, you need to add remote origin in this way
git remote add origin https:
This will basically set the location of the project created in your GitHub. And you only have to add it to your project once, no more pushing next time. That means he will remember from next time. Then you just have to push. Now if you want to push the project, you have to give the following push command:
git push origin master
Or if you want to push a specific branch, you have to give the name of the branch in place of master. For example, the push command for our showTable branch will be as follows:
git push origin showTable
If all goes well, your project will go to GitHub. However, you may need to enter your GitHub username and password here. In this case, you can set up the SSH key for your machine if you want without repeatedly giving the username password while pushing in this way, and if you use SSH, you don’t have to give username and password anymore. If you want to set up SSH, you can take the guide from here.
Pull from GitHub
You may have to pull the project from GitHub for many reasons, many times you do not have the project on your local PC, but previously pushed to gitHub. Again, maybe another collaborator or a team member in your project has pushed it to do something new in your project. Now automatically but that work update will not come from GitHub to your local machine. That’s why you have to pull it from GitHub like this:
git pull origin master
Before you pool, you must see if you have any work left to commit. If so, you have to commit it first. Other than that there may be conflict when pulling a lot of time. This means that many times when two collaborators edit the same file, Git merges those tasks as automatically as possible, much like merging branches. And if there is a conflict, Git highlights the codes of that line with some special writing everywhere. Then we have to go to those places manually and decide which line to put and which line to leave out and then we have to commit the changes again.
Project cloning from GitHub
A lot of the time anyone who is on GitHub has to sit on our local machine to work on any project. Then we have to download a clone copy of that project to our local PC. If you want, you can clone any public project of GitHub like this. For this, first you have to find the link of the clone of the project you will clone. And the cloning link you can go to any project page of GitHub in the top right corner of the project file listing in the button called Clone or download.
However, if you want, you can download the zip file from here. However, the current branch of the GP contains only the files. Git has no configuration. Clone with the command line in git like this:
Here you first need a git clone then a link to the GitHub repository. You can then enter the name of the directory in which you want to place the project on your local machine. It is optional to give the name of the local directory, otherwise the name of the default repository will be cloned in the directory of that name. Suppose, we will clone this project opensourcepos. So I will open the command line and write the following command:
Now if you enter, the project will be slowly cloned to your local machine. Now if you want you can go inside it and use Git while working, you can modify the project locally, you can do everything. And this projector remote will be set automatically from where you cloned. If you are not the Collaborator of this project, you will not be able to push remotely, and if you are the Collaborator, you will be able to push this project, any new commitments you have made.
Creating Pull REQUEST on someone else’s project
Suppose you want to contribute to someone else’s project. Fork is a lot like a clone. The difference is that cloning is like downloading a copy to your local machine. But if you fork, the copy will be created in your GitHub account without downloading to the local machine. You can use that copy as your repository. You can also clone that forked repository and bring it down to the local machine. This fork button is located in the top right corner of GitHub’s desired project page.
After being forked, you can now clone from your account and work on it.