Reputation: 551
I have explored quite a bit to get answer to my question but did not get a satisfying answer, so posting the question here.
I want to create a pull request to the original repository on GitHub, I am following the below process:
First I am creating my branch:
git checkout -b my-branch
Making the changes and then committing:
git add .
git commit -m “Changes made to repo”
Now pushing the brach to the forked master branch:
git push --set-upstream origin my-branch
But before I make a pull request, I also need to update my forked repository’s master branch and make it same as upstream/master.
Q1. Which command to use for updating my forked master branch:
git pull upstream master
, followed by git push origin master
or git merge upstream master
, followed by git push origin master
? (I have already added the upstream url)
Q2. Will my added branch “my-branch” will automatically get updated once I update the forked master brach?
Upvotes: 1
Views: 291
Reputation: 1324278
If you do so from command-line, I would use the new CLI (commad-line interface) github/hub (described here)
Case in point: hub pr
(read) and hub pull-request
(write/creation)
Examples:
$ hub pull-request
[ opens a text editor for writing title and message ]
[ creates a pull request for the current branch ]
$ hub pull-request --base OWNER:master --head MYUSER:my-branch
[ creates a pull request with explicit base and head branches ]
$ hub pull-request --browse -m "My title"
[ creates a pull request with the given title and opens it in a browser ]
$ hub pull-request -F - --edit < path/to/message-template.md
[ further edit the title and message received on standard input ]
Your PR branch is updated only when you push (or force push) commits on it.
Updating another forked branch has no effect.
You would need to merge said other branch to your PR branch or rebase your PR branch on top of said remote forked branch (and then force push) in order for said PR to be updated.
Upvotes: 2