What are Git pull requests and how are they used?

Contents

Git logo

Pull requests are a feature of online git services like Github and Gitlab. They make it possible for anyone to request changes to be added, even if they don't have access to the repository. We will analyze how they work and how to use them for open source collaboration.

What does a pull request do?

Despite what it may seem, git as a tool it is a fully decentralized system. What that means is that the repository on Github.com and the repository on your local machine are no different from each other. You are not connecting for Github to work on a repository, you are copying the code from Github in your local repository and working on it there.

When you want to push changes, can commit and run git push, enviando sus actualizaciones a un “remote” dado, which can be any other Git repository, but in general it is a service hosted online like Github, Bitbucket o Gitlab. This updates the remote repository so that it is in sync with your repository.

Despite this, this only works when you have permission to send confirmations, generally configured with a password or SSH key. This is only given to members of the organization who control the repository; opposite case, everyone could alter the git history. If you are not a member of the organization, What should you do when you want to make changes?

Well, is there a second way to update a git repository:git pull. You probably do this often every time your coworkers make pushy changes.. Then, you are downloading commits from remote repository and syncing them with your local repository.

But, Git is decentralized, so there is truly no difference between your repository and the remote repository. You can truly run git pull the other way, from the server, and this is the heart of what makes pull requests work.

A pull request is just for you to tell the remote server (and the people who maintain it) that you have some updated commits that you would be interested in having them review and integrate with the remote repository. If they accept the changes, the remote repository will run git pull against your local repository, integrating the code without having to have an authorized SSH key to do it.

The backbone of open source collaboration

Pull requests are constantly used for open source libraries. After all, Much of the reason for open source is that any developer can contribute to the project if their code is useful.

Pull requests are what make that work. Those in charge of the maintenance of the project, the administrators who control it, they are the ones who regularly review pull requests and decide whether or not to integrate the code, or if certain errors need to be corrected before it is ready.

Pull requests are not exactly a feature of git per se, so the exact implementation of them will vary according to the service. But, for Github, you will find pull requests in the menu bar of a repository, which displays a list of open and closed requests that you can filter by.

If you click on any of them, you can see the comments made by the requester, as well as the confirmations associated with it.

If you are responsible for maintaining the repository, you can review and merge the request. O, if you have problems with him you need to discuss, you can leave a comment and work together on the code. This is a big reason why public spaces like Github are great for open source collaboration., Even something as simple as changing the wording of the documentation can be done collaboratively by anyone.

Pull requests are different from problems. Issue tracking is a feature of many services like Github that enables easy bug fixes and public collaboration for new features. Essentially, each topic has a topic that maintainers and the community can discuss. As an example, dotnet/csharplang is the official repository for discussion about how C is designed # as a programming language. If you go to the topics, you will find many people discussing concepts for future iterations of the language:

Not all problems lead to pull requests. If the maintenance manager fixes the problem, it won't matter. If a collaborator fixes the problem, you will need to submit a pull request.

All pull requests are rejected or lead directly to code changes in the repository. Issues are just one way to track development progress and what bugs need to be fixed.

Making pull requests

Again, the exact steps for this will vary depending on the service you are using, but most open source collaborations happen on Github, so we will show the steps for that.

Dirígete al repositorio para el que deseas realizar una solicitud y haz un clic enNueva solicitud de extracciónen la pestaña Solicitudes de extracción:

You have two options here. If you are a member of the repository and want to merge your features branch into the master branch, you can choose the two branches.

If you are working on an open source repository, you will need to fork the repository and submit it to Github with your own account. After, You can choose “comparar entre bifurcacionespara fusionar su rama maestra en su rama maestra.

Once this is done, the pull request will be open for discussion, and you will simply have to wait to hear from the maintainers.

In the meantime, puede verificar el estado de todas las solicitudes de extracción en las que está involucrado con la pestañaSolicitudes de extracciónen la barra de encabezado principal.

Subscribe to our Newsletter

We will not send you SPAM mail. We hate it as much as you.