Solved

git merge

Posted on 2011-09-28
2
457 Views
Last Modified: 2012-05-12
Hi Experts,

I have a master and a NewReports branch.  I've been working a lot on the NewReports branch, as well as on the master branch, so there's lots of conflicts to manage.

Let me know if this is good thinking:  while in the NewReports branch, I would like to merge the master branch into it, so that when I eventually merge the changes from the NewReports back into the master branch, there's less to do.

I did run 'git merge master' from within NewReports.  I started stepping through a p4merge but noticed there was a lot of stuff in there that I didn't want (in files that had already been merged).  Example, there was some code in the master branch that got erased within the NewReports and got put back in when I did the merge.  I assume this is because you should never merge this way - only merge stuff from branches into main lines?

Thanks for your input!
Mike
0
Comment
Question by:thready
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
evilrix earned 500 total points
ID: 36812973
Hey Mike.

Yeah, that's not an idea work-flow because, as you've discovered, you end up with lots of merge conflicts.

A few thoughts...

1. Instead of merging you are probably better of rebasing as that will preserve the chronological ordering in which the changes were made. This often leads to far less conflicts (often, but not always).

2. If you make your rebase interactive you'll be able to pick which changes to rebase in.

3. If one branch only has a few changes you might be better off cherry-picking from the branch with the smallest number of changes.

I would aim to have all your work in your dev branch. Once you are in this state if you perform a hard reset back to origin/master of the master branch you can then use that as your baseline branch that you merge all you changes into when you are happy with them in the dev branch.

I would recommend you never develop in master, always in a branch. If you want to experiment in a branch you can always branch again. Avoid working in a child and parent branch at the same time as this prevents the ability to perform a fast-forward merge which means a real merge will take place and that means there is the chance of merge conflicts.

Good luck.
0
 
LVL 1

Author Closing Comment

by:thready
ID: 36907539
A big thanks yet again evilrix!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Starting up a Project

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question