Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple commits in pull requests

We have a dev branch and a release branch. Dev branch is where all the developers check-in the code. All builds are taken from the release branch. We're using Stash (Atlassian's Enteprise Git) and wanted to incorporate code reviews using pull requests.

When someone submits a pull request, it is automatically including all the changesets from the dev branch that are not already merged into the release branch, even if they're not from the user who is submitting the request. How can the developer submit a request only for their changes and not everyone else's? Is this how it's supposed to be?

I see two workarounds -

  1. Add individual branches for each developer so it picks up only their changes.
  2. Add multiple approvers if the pull request has commits from multiple developers.

What is the best practice?

like image 289
tempid Avatar asked Nov 20 '13 06:11

tempid


People also ask

Can a pull request have multiple commits?

A pull will pull all the commits, including their dependencies - it won't cherry-pick individual commits. So if you want to request that only your commits be pulled, and there are other people's commits in the same branch, you have to first separate your commits into a different branch. Yes, it will.

How many commits should be in a pull request?

Have one commit per logical change and one major feature per pull request. When you submit a pull request, all the commits associated with that pull request should be related to the same major feature.

Can I add new commits to pull request?

You can commit changes on a pull request branch that was created from a fork of your repository with permission from the pull request creator. You can only make commits on pull request branches that: are opened in a repository that you have push access to and that were created from a fork of that repository.


2 Answers

A pull request means a "request to pull". A pull will pull all the commits, including their dependencies - it won't cherry-pick individual commits.

So if you want to request that only your commits be pulled, and there are other people's commits in the same branch, you have to first separate your commits into a different branch.

like image 113
Robin Green Avatar answered Sep 27 '22 20:09

Robin Green


What I currently use is this:

We have 3 branches:

  • Develop
  • Release
  • Master

The process is as follows:

  1. For each feature, we create a branch from the Master.
  2. For testing, we make a Pull Request from our branch to the Develop branch.
  3. When done testing, we make a Pull Request from our branch again, but to the Release Branch.
  4. After every release, we make a single Pull Request from Release to Master. Note that this create additional repeated commits that eventually flow back to Develop, but no actual file changes usually occur, only commits.

Notice that in this process the Develop Branch is never merged into Release. After all, it will contain a bunch of code from other developers that isn't ready to be deployed. But my branch will contain only my code.

Just be aware of code that may impact your tests, as it may not go into the release branch at the same time. I would actually like some feedback on this architecture as well.

As an illustration, it's something like this:

  • Master -> My Branch
  • My Branch -> Develop
  • My Branch -> Release
  • Release -> Master
like image 20
George Avatar answered Sep 27 '22 20:09

George