How to Create a Repository and Send a Pull Request on GitHub?

Coding Docs Git

GitHub is a highly popular git remote repository hosting platform along with Bitbucket and GitLab.

In this article, I will show you how to create a remote repository then use it on your local machine, and after making a few changes, how to send a pull request via GitHub.

Let’s begin with creating a remote repository.

Creating a Remote Repository

Let me say that I want to work on a side project with my friends for fun purposes. Like every today’s developer, I want to feel safe and not to lose any of my work during this collaborative development process. Thus I want to use a git repository especially a remote one.

That’s why I created a remote private Git repository on GitHub. Most of the companies are hosting their Git repositories of software projects on GitHub, Bitbucket, Gitlab, or their private servers not to lose any data.

So I go to my GitHub homepage and found the New button to create a new repository.

Then I fill the necessary information about my new repo. I name it my-project, made it private, and add an initial README file by checking the related option.

When I click the Create Repository button, it would create my remote repository and redirects me to the homepage of the project’s repository.

Cloning the Repository to Local Environment

After that, I need to clone this repository to my local machine, because I need an interactive text editor or I need to test my project on my machine. So I click the “Clone or Download” button and see its HTTPS Git URL. Also, there is an SSH option to clone my new repo but right now we won’t deal with this option.

I should copy my repo’s git URL and open my terminal on my machine. I switch to my preferred directory with the “cd” command, and I use the most common git command which is git clone:

$git clone https://github.com/bahadirmezgil/my-project.git

I enter the cloned repository directory and look at the current files

There is only a README.md file as you can see. But also you may have already realized that my terminal is detected that it is a git directory and it also shows me its current branch which is “master”. Also, you can look at hidden files with ls -a command

You will see a hidden git directory which indicates this is a git repo folder. But in some cases, you may not see it in your terminal. But don’t worry.

Checking Git Installation

Most of the operating systems come up with git installation by default. You can check whether your machine has installed git or not by another git command on your terminal:

$git --version

If you don’t see that output or your terminal doesn’t respond to the git repository, I would recommend you to install git via https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

Making Few Changes

Now let’s make a few changes to our local repository. But for that first, we need to create a new branch from our main development branch which is usually called the dev branch. Then with our new branch, we can commit our changes and push it to our remote repository along with the new branch information.

This article doesn’t cover how to use git branches but if you don’t feel confident about them, I strongly recommend you to read my article https://www.codingdocs.com/git-branching-tutorial-with-real-world-examples/ about git branches in detail.

Now we are ready to send a pull request from our new branch.

Send a Pull Request (PR)

The most common and professional approach when using remote repositories is sending pull requests (PR). For other remote git repository hosting platforms, you could see the word Merge Request (MR) like GitLab.

To do that go to the remote repository homepage and you would probably see the pull request button or a plus sign on other platforms.

By clicking one of them, a pull request screen will appear with a select option of which branch of changes should be merged into which branch. In our case, it is feature/my-killer-feature to the dev branch.

By clicking the “Create pull request” button you will send a PR to that repository. Of course, it will not automatically be merged but it will start a code review process. So other teammates will be able to review and comment about our changes. If our code changes have general acceptance, the admin of the remote repository may accept our PR and merge our feature branch to the dev branch.

Conclusion

I hope this article helped you with how to create a remote repository and how to send a pull request to your remote repository via GitHub.

If you want to learn more about Programming, don’t forget to subscribe to our newsletter and if you have any questions, please don’t hesitate to contact me.

See you in new articles.

Leave a Reply

Your email address will not be published. Required fields are marked *