Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pull-Request for only certain files/commits

I have a repository that is forked from GitHub that has a few modifications made to it. However, in a certain commit, a few files were changed that I want to submit a pull-request for, leaving the other modified files out of the request.

Do pull requests merge all commits, or do I need to do something special to isolate this commit?

like image 798
Qix - MONICA WAS MISTREATED Avatar asked Sep 30 '12 11:09

Qix - MONICA WAS MISTREATED


People also ask

How do I only put certain files in a pull request?

Pull requests merge branches. So if you want to isolate some things for a pull request, best is to put those changes in a separate branch. Advantage is that you can change the pull request by pushing new changes to that branch (even push -f if you need to change already pushed commits).

How do you git pull a specific commit?

How do I pull a specific commit? The short answer is: you cannot pull a specific commit from a remote. However, you may fetch new data from the remote and then use git-checkout COMMIT_ID to view the code at the COMMIT_ID .


1 Answers

A pull request being made of whole commits, you need to split this commit into two separate commits one containing the change to put in the pull request, and the other holding the other changes. To do this you need git rebase -i, see for example How can I split up a Git commit buried in history? for a good explanation on how to do it.

Once you have split the commit, move the ones you want to include into a topic branch, see for example How to move certain commits to another branch in git?, but it depends if the commits that make your pull request are sequential.

Then finally you can push to Github and create the pull request from your topic branch.

like image 102
CharlesB Avatar answered Oct 17 '22 01:10

CharlesB