Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

git merge

Posted on 2011-09-28
2
Medium Priority
?
460 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
2 Comments
 
LVL 40

Accepted Solution

by:
evilrix earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

971 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