[development] using git, create patch with new files

Steven Jones steven.jones at computerminds.co.uk
Mon Apr 11 21:27:09 UTC 2011

Hi Dave,

I think that the main thing your missing is that you're still stuck in
the old ways of CVS, when you weren't allowed to commit to the repo.
Now you have your own copy of the entire repo, and you can do whatever
you like with it. By far the easiest way to do some work and generate
a patch is to start by branching:

git checkout -b dev-new-work-123456

Then you do some work, maybe edit file a file here, and create a file
there, then you add those to the 'index':

git add edited.file.php
git add created.file.php

Then you can commit those changes:

git commit

Then you can repeat, do some more work, add and commit until you're done.
At this point you'll have two branches of work, the clean copy of
(say) 6.x-1.x and yours, which you can now diff easily:

git diff 6.x-1.x

This will give me a diff of my current branch (dev-new-work-123456)
with 6.x-1.x, which will be the patch file you're after. Not being
scared of branching and committing really is the key to effectively
using git.

Git really does change the way you work, and for the better, give it a
year and you'll wonder how you managed before!

Steven Jones
ComputerMinds ltd - Perfect Drupal Websites

Phone : 024 7666 7277
Mobile : 07702 131 576
Twitter : darthsteven

On 11 April 2011 21:32, Dave Cohen <drupal at dave-cohen.com> wrote:
> On Monday 11 April 2011 13:09:20 Michael Favia wrote:
>> I'm no more  a"fan" of git than i am of drupal. Its a tool that has good
>> value if you know how to use it and can frustrate the hell out of you if
>> you dont.
> Let's just say it frustrates the hell out of me.  :)
>> It just has one more layer of intelligence/workflow that allows it/you
>> to ignore changes in your working copy that you don't want to pay
>> attention right now.
> In my case there are modified files, and added files, and I want git to pay attention to both of those groups.
>> > I find that "git diff HEAD" is wrong because I'm not working on HEAD.  Similarly, "git diff origin" does not do the right thing.
>> You find that its wrong or it doesnt work? These are two different things.
> Wrong for my case, I meant.  I thought I tried both "git diff HEAD" and "git diff origin" and both produced a diff with too many changes.  But I tried again, and "git diff HEAD" did what I wanted.  So I guess I was seeing things for a moment there.
> git diff origin             <--- does the wrong thing, in my case
> git diff HEAD             <--- appears to work
> git diff origin/6.x-3.x  <-- appears to work, in my case
> (I also add --no-prefix when running git diff, at least when I remember)
>> HEAD is a special dynamic variable that refers to the most recent commit
>> in the index. It is there so you don't have to type in the whole commits
>> crazy ass SHA name. In that way it works EXACTLY like a named version
>> tag.  (fyi HEAD^ equals "next to last commit" so git "diff HEAD^ HEAD"
>> shows you the diff between the last commit and the one before it).
> Thanks for explaining that.
> -Dave

More information about the development mailing list