Reputation: 486
I've read the docs, I've looked at similar questions and I must still be overlooking something extremely simple.
Here's what I want to accomplish:
issue1
, commit a fix for issue #1, push.issue1
, only with the fix for issue #1.issue2
, commit a fix for issue #2, push.issue2
, only with the fix for issue #2.Here's what I did:
git checkout master
git pull upstream master
git checkout -b issue1
echo "123" > issue1.txt && git add issue1.txt
git commit -m "issue1 fix"
git push origin issue1
git checkout -b issue2
echo "123" > issue2.txt && git add issue2.txt
git commit -m "issue2 fix"
git push origin issue2
I made pull requests from both branches (PR 1 and PR 2), and the one from issue2
has both commits (from both branches). How can I avoid this when working on multiple issues/branches at the same time?
Upvotes: 2
Views: 1571
Reputation: 4159
When you created the issue2
branch, you branched off issue1
to create it. Unless you provide a second argument to git branch
(or git checkout -b
in your case) to indicate the starting branch, the created branch will be based off the current branch - which in your case is issue1
.
To fix your problem, either switch back to master
before creating issue2
, or execute git checkout -b issue2 master
.
Upvotes: 2