Solved

git merge

Posted on 2011-09-28
2
451 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 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
A short article about problems I had with the new location API and permissions in Marshmallow
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now