Solved

git merge

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

A short article about a problem I had getting the GPS LocationListener working.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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 …

828 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