Confused about github rebasing

Alex Rønne Petersen xtzgzorex at gmail.com
Thu Mar 15 13:51:30 PDT 2012


On 15-03-2012 21:49, H. S. Teoh wrote:
> On Thu, Mar 15, 2012 at 08:59:57PM +0100, Alex Rønne Petersen wrote:
>> On 15-03-2012 20:13, H. S. Teoh wrote:
>>> I'm trying to submit a pull request for druntime, but I'm running into a
>>> git problem. This is what I did:
>>>
>>> - (I forgot that my master branch is out of date)
>>> - created a new branch for the fix and committed some changes
>>> - switched to master and ran 'git pull'
>>> - now master is ahead of the branch by a number of commits
>>> - switched back to branch
>>> - ran 'git rebase master' to pull in changes from master and apply my
>>>    changes on top of it
>>> - checked that history looks clean
>>> - 'git push -u origin newbranch'
>>> - submit pull request: but now github thinks my branch has a whole bunch
>>>    of commits I didn't make (looks like the commits made by rebase).
>>>
>>> So my question is, what did I do wrong, and what's the right way to
>>> pull in the latest changes from upstream without messing up the history?
>>>
>>>
>>> T
>>>
>>
>> Let's say you're on your branch with your commits. You have a remote
>> called dpl, which is upstream. So:
>>
>> $ git fetch dpl
>> $ git pull --rebase dpl master
>> $ git push origin<your branch>  -f
>>
>> Note the -f, since you're overwriting remote history in your repo.
> [...]
>
> OK thanks!
>
> Another question. How to I repair my current history, which is all
> messed up now? That is, my branch has a whole bunch of commits I didn't
> make; how do I clean it up? Or is it easier to start from scratch? :)
>
>
> T
>

Well, it really depends on how the history looks... How many commits do 
you have? If it's a small number, just branch off upstream and 
cherry-pick each commit.

-- 
- Alex


More information about the Digitalmars-d-learn mailing list