Questions tagged [merge]

Merging is a generic term for combining two or more related sets of data. It is commonly associated with revision control systems when reconciling multiple changes made to a revision-controlled collection of files. Merging multiple data sets is another use of this tag.

Most often, it is necessary when a file is modified by two people on two different computers at the same time. When two branches are merged, the result is a single collection of files that contains both sets of changes.

In some cases, the merge can be performed automatically, because the changes do not conflict. In other cases, a person must decide exactly what the resulting files should contain. Many revision control software tools include merge capabilities.

Merge can be used as a verb ("to merge branches"), but can also be a noun ("this merge will be difficult").

Merging multiple data sets is another use of this tag.

Merge can also refer to the Ruby Hash#merge method for merge hashes or git merge command for git revision control system.

Merge is different from join in datasets which is primarily SQL based. Difference between merge and join for SAS is here http://www2.sas.com/proceedings/sugi30/249-30.pdf and for R is here How to join (merge) data frames (inner, outer, left, right)?

See Wikipedia: Merge Version Control.

24925 questions
255
votes
5 answers

How to keep the local file or the remote file during merge using Git and the command line?

I know how to merge modification using vimdiff, but, assuming I just know that the entire file is good to keep or to throw away, how do I do that? I don't want to open vimdiff for each of them, I change want a command that says 'keep local' or…
Bite code
  • 578,959
  • 113
  • 301
  • 329
255
votes
9 answers

Undo a merge by pull request?

Someone accepted a pull request which they shouldn't have. Now we have a bunch of broken code merged in. How do you undo a pull request? I was just going to revert the changes to the commit just before the merge, but I noticed that it merged in a…
Will
  • 10,013
  • 9
  • 45
  • 77
254
votes
4 answers

Why is a 3-way merge advantageous over a 2-way merge?

Wikipedia says a 3-way merge is less error-prone than a 2-way merge, and often times doesn't need user intervention. Why is this the case? An example where a 3-way merge succeeds and a 2-way merge fails would be helpful.
Johannes Bittner
  • 3,503
  • 2
  • 23
  • 21
243
votes
4 answers

How to correctly close a feature branch in Mercurial?

I've finished working on a feature branch feature-x. I want to merge results back to the default branch and close feature-x in order to get rid of it in the output of hg branches. I came up with the following scenario, but it has some issues: $ hg…
Andrey Vlasovskikh
  • 16,489
  • 7
  • 44
  • 62
242
votes
4 answers

Merging 2 branches together in Git

I've only just started to use Git and think it is wonderful, however I'm a little confused over what the merge command does. Let us say we have a working project in the branch "A". I go home and make changes to this branch and save it as…
dotty
  • 40,405
  • 66
  • 150
  • 195
223
votes
8 answers

How to test a merge without actually merging first

Is there any way of simulating a git merge between two branches, the current working branch and the master, but without making any changes? I often have conflicts when I have to make a git merge. Is there any way of simulating the merge first?
dole doug
  • 34,070
  • 20
  • 68
  • 87
222
votes
7 answers

Git merge with force overwrite

I have a branch called demo which I need to merge with master branch. I can get the desired result with following commands: git pull origin demo git checkout master git pull origin master git merge demo git push origin master My only concern is, if…
OpenStack
  • 5,048
  • 9
  • 34
  • 69
221
votes
6 answers

Python Pandas merge only certain columns

Is it possible to only merge some columns? I have a DataFrame df1 with columns x, y, z, and df2 with columns x, a ,b, c, d, e, f, etc. I want to merge the two DataFrames on x, but I only want to merge columns df2.a, df2.b - not the entire DataFrame.…
BubbleGuppies
  • 5,750
  • 7
  • 20
  • 15
217
votes
11 answers

How to "git show" a merge commit with combined diff output even when every changed file agrees with one of the parents?

After doing a "simple" merge (one without conflicts), git show usually only shows something like commit 0e1329e551a5700614a2a34d8101e92fd9f2cad6 (HEAD, master) Merge: fc17405 ee2de56 Author: Tilman Vogel Date: Tue Feb 22 00:27:17…
Tilman Vogel
  • 9,337
  • 4
  • 33
  • 32
212
votes
2 answers

How can I discard remote changes and mark a file as "resolved"?

I have some local files, I pull from remote branch and there are conflicts. I know that I would like to keep my local changes and ignore the remote changes causing conflicts. Is there a command I can use to in effect say "mark all conflicts as…
Tom DeMille
  • 3,207
  • 3
  • 23
  • 30
211
votes
35 answers

How to merge dictionaries of dictionaries?

I need to merge multiple dictionaries, here's what I have for instance: dict1 = {1:{"a":{A}}, 2:{"b":{B}}} dict2 = {2:{"c":{C}}, 3:{"d":{D}}} With A B C and D being leaves of the tree, like {"info1":"value", "info2":"value2"} There is an unknown…
fdhex
  • 2,212
  • 2
  • 16
  • 13
207
votes
5 answers

How to merge 2 List and removing duplicate values from it in C#

I have two lists List that I need to combine in third list and remove duplicate values from that lists A bit hard to explain, so let me show an example of what the code looks like and what I want as a result, in sample I use int type not…
Kiquenet
  • 14,494
  • 35
  • 148
  • 243
200
votes
3 answers

How do you rebase the current branch's changes on top of changes being merged in?

Okay. If I'm on a branch (say working), and I want to merge in the changes from another branch (say master), then I run the command git-merge master while on the working branch, and the changes get merged in without rebasing the history at all. If I…
Jonathan M Davis
  • 37,181
  • 17
  • 72
  • 102
200
votes
14 answers

Select rows from one data.frame that are not present in a second data.frame

I have two data.frames: a1 <- data.frame(a = 1:5, b=letters[1:5]) a2 <- data.frame(a = 1:3, b=letters[1:3]) I want to find the rows a1 have that a2 doesn't. Is there a built in function for this type of operation? (p.s: I did write a solution for…
Tal Galili
  • 24,605
  • 44
  • 129
  • 187
198
votes
3 answers

How do I merge multiple lists into one list?

I have many lists: ['it'] ['was'] ['annoying'] I want to merge those into a single list: ['it', 'was', 'annoying']
user1452759
  • 8,810
  • 15
  • 42
  • 58