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
634
votes
29 answers

Merging dictionaries in C#

What's the best way to merge 2 or more dictionaries (Dictionary) in C#? (3.0 features like LINQ are fine). I'm thinking of a method signature along the lines of: public static Dictionary
orip
  • 73,323
  • 21
  • 116
  • 148
594
votes
6 answers

What is the difference between merge --squash and rebase?

I'm trying to understand the difference between a squash and a rebase. As I understand it, one performs a squash when doing a rebase.
GiH
  • 14,006
  • 13
  • 43
  • 56
576
votes
17 answers

How to import existing Git repository into another?

I have a Git repository in a folder called XXX, and I have second Git repository called YYY. I want to import the XXX repository into the YYY repository as a subdirectory named ZZZ and add all XXX's change history to YYY. Folder structure…
Vijay Patel
  • 17,094
  • 6
  • 31
  • 35
520
votes
10 answers

What is the precise meaning of "ours" and "theirs" in git?

This might sound like too basic of a question, but I have searched for answers and I am more confused now than before. What does "ours" and "theirs" mean in git when merging my branch into my other branch? Both branches are "ours". In a merge…
CommaToast
  • 11,370
  • 7
  • 54
  • 69
514
votes
5 answers

Simple tool to 'accept theirs' or 'accept mine' on a whole file using git

I don't want a visual merge tool, and I also don't want to have to vi the conflicted file and manually choose the between HEAD (mine) and the imported change (theirs). Most of the time I either want all of their changes or all of mine. Commonly…
nosatalian
  • 6,889
  • 4
  • 20
  • 16
498
votes
12 answers

How do I merge changes to a single file, rather than merging commits?

I have two branches (A and B) and I want to merge a single file from branch A with a corresponding single file from Branch B.
Isuru
  • 7,893
  • 8
  • 30
  • 38
495
votes
15 answers

How do I concatenate or merge arrays in Swift?

If there are two arrays created in swift like this: var a:[CGFloat] = [1, 2, 3] var b:[CGFloat] = [4, 5, 6] How can they be merged to [1, 2, 3, 4, 5, 6]?
Hristo
  • 6,382
  • 4
  • 24
  • 38
465
votes
3 answers

What to do with branch after merge

I had two branches: master and branch1. I just merged branch1 back into master and I'm done with that branch. Should I delete it or just let it sit around? Will deleting it cause any loss of data?
Alison
  • 5,630
  • 4
  • 18
  • 26
463
votes
4 answers

When would you use the different git merge strategies?

From the man page on git-merge, there are a number of merge strategies you can use. resolve - This can only resolve two heads (i.e. the current branch and another branch you pulled from) using 3-way merge algorithm. It tries to carefully detect…
Otto
  • 18,761
  • 15
  • 56
  • 62
419
votes
20 answers

GitHub pull request showing commits that are already in target branch

I'm trying to review a pull request on GitHub to a branch that isn't master. The target branch was behind master and the pull request showed commits from master, so I merged master and pushed it to GitHub, but the commits and diff for them still…
lobati
  • 9,284
  • 5
  • 40
  • 61
415
votes
23 answers

Git merge reports "Already up-to-date" though there is a difference

I have a git repository with 2 branches: master and test. There are differences between master and test branches. Both branches have all changes committed. If I do: git checkout master git diff test A screen full of changes appears showing the…
Charles Darke
  • 4,461
  • 3
  • 18
  • 9
411
votes
7 answers

How and/or why is merging in Git better than in SVN?

I've heard in a few places that one of the main reasons why distributed version control systems shine, is much better merging than in traditional tools like SVN. Is this actually due to inherent differences in how the two systems work, or do…
Mr. Boy
  • 60,845
  • 93
  • 320
  • 589
404
votes
6 answers

merge one local branch into another local branch

I have multiple branches which are branched off the master (each in a separate subdirectory). Branch1: new development, not yet completely finished Branch2: hotfix for a problem, but still under test Branch3: mess around branch, which I will not…
Nemelis
  • 4,858
  • 2
  • 17
  • 37
387
votes
4 answers

What Git branching models work for you?

Our company is currently using a simple trunk/release/hotfixes branching model and would like advice on what branching models work best for your company or development process. Workflows / branching models Below are the three main descriptions of…
HiQ CJ
  • 3,406
  • 3
  • 17
  • 11
364
votes
10 answers

How to merge lists into a list of tuples?

What is the Pythonic approach to achieve the following? # Original lists: list_a = [1, 2, 3, 4] list_b = [5, 6, 7, 8] # List of tuples from 'list_a' and 'list_b': list_c = [(1,5), (2,6), (3,7), (4,8)] Each member of list_c is a tuple, whose…
rubayeet
  • 9,269
  • 8
  • 46
  • 55