[development] using git, create patch with new files

Dave Reid dave at davereid.net
Mon Apr 11 22:32:06 UTC 2011


Dev list:

Yeah I've definitely learned that you might be much better off using the
'create branches for features and delete them when done, or make them public
to allow people to help' method rather than the old CVS 'make changes and
then a patch' method of development. It's a transition, but I think it works
really well once you get used to it. And I'm one of the biggest
CVS curmudgeons in Drupal.

Dave Reid
dave at davereid.net


On Mon, Apr 11, 2011 at 4:42 PM, Bob Hutchinson <hutchlists at midwales.com>wrote:

> On Monday 11 April 2011, Dave Cohen wrote:
> > I'm trying, and failing, to create a patch that adds new files to a
> module.
>
> Here is a simple way to pull together a patch on a drupal project.
>
> Create a new directory, let's call it 'git-sandbox'
> cd into it and run something like this:
>
> git clone --branch 6.x-3.x http://git.drupal.org/project/mymodule.git
>
> This will create a directory 'mymodule' (or whatever you fetched)
>
> copy your changed files into it and run
>
> git diff > mymodule.patch
>
> if you are adding new files copy them in and run 'add .'
>
> cd in and run
>
> git diff --staged > mymodule.patch
>
> To do both at the same time
>
> git diff HEAD > mymodule.patch
>
> As Sam Boyer explains earlier in this thread.
>
> open the patchfile in your editor and eyeball to see if it makes any sense
>
> If that's OK copy the patchfile away somewhere and delete
> the whole mymodule directory and run the git clone command again, copy the
> patchfile back in and run
>
> git apply mymodule.patch
> or
> patch -p1 < mymodule.patch
>
> if it applies cleanly you are ready to upload the patch to the issue queue
> or wherever.
>
> Of course a git clone run using http cannot be used for commits so it is
> 'safer' as it were.
>
> You can also do all this and a lot more using a tool like Smartgit though
> many would argue that learning it on the command line is better for
> understanding it, true enough.
>
> Another *big* help is to install the git docs (as well as php, mysql etc)
> on your devbox.
>
> Hope this helps.
>
> >
> > According to http://drupal.org/node/707484, I should simply run `git add
> > ...` then "Next time you run git diff, these new files will be included
> as
> > well."  In my experience, this statement is false.
> >
> > When I run `git status`, I see something like this:
> >
> > [dave at starbuck fb-3]$ git status
> > # On branch 6.x-3.x
> > # Changes to be committed:
> > #   (use "git reset HEAD <file>..." to unstage)
> > #
> > #       new file:   fb.process.inc
> > #       new file:   fb_tab.js
> > #
> > # Changes not staged for commit:
> > #   (use "git add <file>..." to update what will be committed)
> > #   (use "git checkout -- <file>..." to discard changes in working
> > directory) #
> > #       modified:   README.txt
> > #       modified:   contrib/fb_example.module
> > #       modified:   fb.module
> > #       modified:   fb_canvas.admin.inc
> > #       modified:   fb_canvas.module
> > #       modified:   fb_devel.module
> > #       modified:   fb_settings.inc
> > #       modified:   fb_tab.admin.inc
> > #       modified:   fb_tab.info
> > #       modified:   fb_tab.module
> > #       modified:   fb_url_rewrite.inc
> >
> >
> > When I run `git diff`, I see changes to all the modified files, but I do
> > not see the new files.
> >
> > What am I missing?  Thanks,
> >
> > -Dave
>
>
> --
> -----------------
> Bob Hutchinson
> Midwales dot com
> -----------------
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20110411/ee3ab024/attachment.html 


More information about the development mailing list