Solved

git merge

Posted on 2011-09-28
2
456 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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?

737 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