I've made multiple changes to two files in a Git repository (specifically, added two formulae to brew).
I committed the changes individually:
git commit file1 git commit file2
I then did one push to GitHub:
git push [email protected]:myname/homebrew.git
I'd now like to send two pull requests to the upstream repository, one for file1, one for file2. Is this possible?
Short Answergit checkout origin/master -- path/to/file // git checkout <local repo name (default is origin)>/<branch name> -- path/to/file will checkout the particular file from the downloaded changes (origin/master).
You can't clone a single file using git. Git is a distributed version control system, the Idea behind its clone functionality is to have a complete copy of project and all versions of files related to that project.
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).
Marking duplicates To mark an issue or pull request as a duplicate, type "Duplicate of" followed by the issue or pull request number it duplicates in the body of a new comment.
If you changed both files in the same commit, then no, this isn't possible. Pushes and pulls operate at a commit level; they won't split them apart.
If you haven't shared the changes yet, you could split the commit into two, making a branch for each, and then initiate pull requests for those.
This is one of those things there are many ways to do, but for example, you could do something like this:
# make sure the commit in question is the most recent # make branch to point to the previous commit, leaving the changes in your work tree git reset HEAD^ # commit the changes to the first file git add file1 git commit # make a branch for the first commit git branch first-branch HEAD^ # commit the changes to the second file git add file2 git commit # create and check out a branch for this commit git checkout -b second-branch # rebase the branch back, so that it doesn't include the first commit git rebase --onto HEAD^^ HEAD^ second-branch # point your master branch somewhere that makes sense - maybe before either branch git checkout master git reset --hard first-branch^
This would leave you with history like this:
- x (master) - A (first-branch) \ - B (second-branch)
where commit A modified file1, and commit B modified file2.
Once the history looks the way you like it, you can push the two branches separately and do what you need to do with them:
git push origin first-branch second-branch
Put each file on its own branch. You can generate a pull request for each branch, which should do what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With