[LRUG] git question

Chris Mear chrismear at gmail.com
Thu Aug 20 04:17:34 PDT 2009


On 20 Aug 2009, at 11:59, Taryn East wrote:

> 2009/8/20 Chris Mear <chrismear at gmail.com>
>
>> Sounds like what you've missed is git-rebase. This command replays  
>> the commits from a given branch back on top of the latest head of  
>> (usually) your master branch.
>>
>> Then you can create a patch based on the diff  
>> master..hyperactionpack and it will apply cleanly.
>>
>> While you're doing the rebase, if it tries to replay a commit that  
>> doesn't apply cleanly to the latest master, you'll get a chance to  
>> fix it, just as if you were doing a regular merge.
>>
>> As an aside, the whole 'pull request' thing is a GitHub-specific  
>> thing; the Rails team in particular has said that they want  
>> patches, not pull requests via GitHub, so this approach is probably  
>> the best way.
>
>
> This is what I did on my fork, and it still didn't seem to help :(
>
> Perhaps I used it the wrong way?
>
> Every couple of days I did a git pull and rebase.
>
> Now the patches I created weren't an "everything from when I  
> branched until the present day"... because I had several chunks of  
> functionality to send in - and wanted four separate patches...
>
> but the very first of these wouldn't apply as the code of the  
> underlying file (ActiveResource::Validations)  had changed, so the  
> patch was saying that it referred to line 8 - and line 8 no longer  
> matched where the changes had been made.

If the patches weren't applying cleanly, then it sounds like you  
weren't rebasing properly. A successful rebase will rewrite your  
feature commits and add them directly on top of the latest master, so  
by definition a diff from that master to your feature head will apply  
cleanly to that master.

Without seeing your repository, it's pretty hard to tell what  
happened. One possibility is that your git pull wasn't set up  
correctly. In the situation where you've made a GitHub fork of the  
Rails repository, you've actually got three repositories that you're  
playing with:

* the original rails/rails remote repository;
* your fork, the taryneast/rails remote repository; and
* your local repository.

If you created your local repository by cloning taryneast/rails, then  
doing a git pull won't pull in the latest changes from the rails/rails  
repository -- it would only pull in changes from your fork. GitHub  
forks don't automatically keep in sync with the original repo.

The way I have my local Rails repository set up, my 'origin' remote is  
the original rails/rails repo, and I have a 'chrismear' remote which  
tracks my GitHub fork.

I then keep my local master branch in sync with the rails/rails master  
by doing:

git fetch origin
git merge origin/master master

(Never been a big fan of git-pull; I prefer doing the fetch and merge  
explicitly so I know exactly what's going on.)

If you do a 'git pull', and then look at the latest commit on your  
local master branch (git show master), does it match the latest commit  
at http://github.com/rails/rails/ ?

Chris




More information about the Chat mailing list