batman
batman

Reputation: 5380

How to pull into all branches?

I'm contributing to a project on GitHub.

I did the following:

  1. forked the repo
  2. clone the forked repo
  3. created a local branch in my local repo
  4. fixed a bug in the local branch
  5. pushed the changes to my forked repo
  6. made a pull request from that new branch

After many days, I got some comments and I have to make some more changes.

But their code has changed a lot since then. If I have to make a pull request again, I must update my new branch with their updated code and merge my changes.

How do I do this?

EDIT:

Before any of this my git log looked like this:

commit A "feature done" (latest, what I wanted to push)

commit B "feature still acting weird"

I exactly did as VonC suggested (except that I was in my feature branch when I fetched).

My rebase had conflicts. When I tried resolving them I was surprised to find that it was rebasing commit B and not A over the upstream master. I've checked this many times: git log shows exactly what I showed.

Why is it rebasing a previous commit of mine over the upstream master?

EDIT: I fixed the above issue by squashing my 2 commits A and B into one. Don't know why it happened though...

Upvotes: 1

Views: 127

Answers (1)

VonC
VonC

Reputation: 1324937

You need to:

  • add the original repo as a new remote:

    git remote add upstream https://github.com/user/repo
    
  • fetch from "upstream"

    git fetch upstream
    
  • rebase your brach on top of upstream/master

    git checkout yourBranch
    git rebase upstream/master
    
  • force a push to your fork: that will update your pull request automatically:

    git push --force origin yourBranch
    

Upvotes: 2

Related Questions