1

I've got a bare repo setup with the following branches:

dev
*master
stage
prod

I've cloned this to a working copy and issued the following commands:

git checkout -b stage remotes/origin/stage
git checkout -b dev remotes/origin/dev

What I need to do is push the entire contents of my staging branch into my dev branch. Basically, this is a first-time setup, and I started with pushing production code into a staging branch (worked flawlessly) and now I'm pushing my staging code into the dev branch.

The problem I'm encountering is a merge conflict on binary files. How do I tell git to not even LOOK at merge-conflicts, and instead just straight up copy over the contents of the stage branch into the dev branch?

pagid
  • 13,559
  • 11
  • 78
  • 104
John Zumbrum
  • 2,786
  • 8
  • 36
  • 60

3 Answers3

3

Sounds like --s ours option of merge is right what you need.

http://book.git-scm.com/5_advanced_branching_and_merging.html

Dmitry Ovsyanko
  • 1,416
  • 11
  • 6
  • Interesting, can you git remote add a repo you've cloned from? Seems like that wouldn't be allowed... – John Zumbrum Feb 01 '12 at 02:38
  • @JohnZ The only thing that could block it is the name collision. There can't be 2 `origin` remotes, but many remotes with the same URL as the `origin`al. – Dmitry Ovsyanko Feb 05 '12 at 12:05
2

You have a few options:

  1. Merge with the "ours" strategy
  2. Merge normally and then amend the merge commit after with 'git checkout HEAD^ -- .'
  3. Reset the dev branch to point to staging with 'git reset --hard staging'
  4. Don't merge but just commit what's in staging after 'git checkout staging -- .'

Options 1 and 3 are probably best. You need to know the DAG (google "git for computer scientist").

We use this work flow: https://plus.google.com/109096274754593704906/posts/R4qkeyRadLR

It's been very good for us.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
1

Decided the simplest way to fix it was to do this:

clone the repo twice, once into a dev folder once into a stage folder then

cd dev
git rm -rf *
git commit -a -m "take that n00b repo!"
git push
cp -r ../stage/* .
git add *
git commit -a -m "how you like dem apples??"
git push

Inelegant but it got the job done, and was a lot less painful than dealing with git's merge conflicts.

John Zumbrum
  • 2,786
  • 8
  • 36
  • 60