threads / discuss / 22552

Fwd: how to apply patch?

Subject: Fwd: how to apply patch?

## tl;dr

4 messages between Feb 7, 2010 and Feb 7, 2010.

replies: 3people: 2as markdown or json

Matt Di Pasquale· Feb 7, 2010, 02:05 UTC · lore

I have a development version & a production version of my website. There are a few essential differences between them that I want to always stay different (like path constants, etc). When I make changes on the dev version and test it out and they work and am ready to copy them to the production (www) version, how do i do that without annihilating the essential differences that i want to keep? I was thinking of creating a patch or branch or something with the differences. Then, copy dev to pro, then reapply/rebase the essential differences to pro that got wiped out. if i rebase though, i want to be able to rebase again on the next edit. what's a good way to do this?

My dir structure:
example.com
  www  # production site
  dev   # development site

Via DreamHost control panel: www.example.com points to example.com/www/ dev.example.com points to example.com/dev/

Why don't I just have a branch called dev? Maybe I should... Advice? (Anyway, it's nice to be able quickly, simultaneously open corresponding files from both www & dev in textmate. I guess I could do that with like git show master:www/index.html | mate or something, but then it opens in a new textmate window. it's just not the same. I guess there's always the possibility of editing www/index.html when I actually want to be editing dev/index.html, but then again, it's also possible to be editing the wrong branch.)

My .git/config file has the following aliases for deployment:

# deploy dev ddev = !rsync -avi --copy-unsafe-links --exclude='*.DS_Store' --delay-updates --delete-after --delete-excluded -e ssh ~/Sites/example.com/dev/ acani@acani.com:Sites/example.com/dev/

# deploy www dpro = !rsync -avi --copy-unsafe-links --exclude='*.DS_Store' --delay-updates --delete-after --delete-excluded -e ssh ~/Sites/example.com/www/ username@example.com:Sites/example.com/www/

Thanks!
Matt
Tay Ray Chuan· Feb 7, 2010, 04:40 UTC · re: Matt Di Pasquale · lore

Re: how to apply patch?

Hi,

On Sun, Feb 7, 2010 at 10:05 AM, Matt Di Pasquale <liveloveprosper@gmail.com> wrote:

Show 5 quoted lines
> [snip]
> Then, copy dev to pro, then reapply/rebase the essential
> differences to pro that got wiped out. if i rebase though, i want to
> be able to rebase again on the next edit.
> what's a good way to do this?
you could put this in your config:
  [remote local]
    url = .
    fetch = dev
  [branch "pro"]
    remote = local
    rebase = true

When you're wish to incorporate your latest changes in "dev" into "pro(duction)",

  $ git checkout pro #assuming you're not already on "pro"
  $ git pull
Repeat ad nauseum.
-- 
Cheers,
Ray Chuan
Matt Di Pasquale· Feb 7, 2010, 06:06 UTC · re: Tay Ray Chuan · lore

Re: how to apply patch?

Hi Ray,

Thanks for your response. I don't understand how that will transfer my latest changes in ./dev into ./www while preserving the fundamental differences between the 2 directories. Could you please provide some explanation?

Also, is there an easy way to do something like this with a branch instead of a remote? Remote doesn't make sense to me conceptually (and I already have a remote repo setup that I push to from master). Maybe I should have 2 different branches? One for dev & one for pro. How would I do that?

Thanks,
-Matt
Tay Ray Chuan· Feb 7, 2010, 13:00 UTC · re: Matt Di Pasquale · lore

Re: how to apply patch?

Hi,

On Sun, Feb 7, 2010 at 2:06 PM, Matt Di Pasquale <liveloveprosper@gmail.com> wrote:

> [snip]
> Also, is there an easy way to do something like this with a branch
> instead of a remote? Remote doesn't make sense to me conceptually (and
> I already have a remote repo setup that I push to from master).

I'm already doing this with branches. It's true that I used a remote configuration, but the remote configuration ("[remote local]") says that we're treating the local repository as the remote repo ("url = .") and to "fetch" the dev branch (into FETCH_HEAD).

(btw, instead of '[remote local]' it should be '[remote "local"]'.)

I do this so that you can just type "git pull" without specifying the branch, unlike when using git-rebase.

> Maybe
> I should have 2 different branches? One for dev & one for pro. How
> would I do that?
You should.
Your history for the two branches would look like this:
a---b---c dev
         \
          A---B---C pro
(if you're reading this in a non-fixed width font, pro branches off at "c".)
The commits in uppercase (A, B, C) are those that are applied onto dev
- for example, changing file paths, configuration, etc.

Let's say you've made some changes onto your dev branch. To update your production site, you would rebase your pro changes onto the dev branch (using the config and commands in the previous message), so that you get this history:

a---b---c---d---e dev
                 \
                  A'---B'---C' pro
(pro branches off at dev's tip, "e".)

You have to keep in mind several issues. For example, if you're updating file paths, when new files are added in the dev branch, you need to update the pro side to modify the file paths in those files. I was also assuming your dev branch fast-forwards cleanly, or else the rebase fumbles.

-- 
Cheers,
Ray Chuan

← back to recent threads