Questions tagged [git-merge]

git-merge is a git command which integrates changes from another branch by incorporating commits into the currently checked-out branch.

A merge in version control is an operation where two sets of changes are combined to have both features available.

Git provides sophisticated merge support by automatically detecting simple merges (i.e. if only changes on one branch happened, also called fast-forward) and allowing plugable merge-strategies for more advanced use-cases.

2864 questions
831
votes
15 answers

Merge development branch with master

I have two branches namely master and development in a GitHub Repository. I am doing all my development in development branch as shown. git branch development git add * git commit -m "My initial commit message" git push -u origin development Now I…
Pawan
  • 28,159
  • 84
  • 232
  • 394
807
votes
19 answers

Is there a git-merge --dry-run option?

I'm merging in a remote branch that may have a lot of conflicts. How can I tell if it will have conflicts or not? I don't see anything like a --dry-run on git-merge.
Otto
  • 16,619
  • 14
  • 54
  • 62
776
votes
13 answers

Get changes from master into branch in Git

In my repository I have a branch called aq which I'm working on. I then committed new work and bugs in master. What is the best way to get those commits into the aq branch? Create another new branch out of master and merge it with aq?
Slee
  • 24,982
  • 48
  • 139
  • 237
775
votes
20 answers

What's the simplest way to list conflicted files in Git?

I just need a plain list of conflicted files. Is there anything simpler than: git ls-files -u | cut -f 2 | sort -u or: git ls-files -u | awk '{print $4}' | sort | uniq I guess I could set up a handy alias for that, however was wondering how pros…
inger
  • 17,374
  • 9
  • 45
  • 51
724
votes
18 answers

Merge, update, and pull Git branches without using checkouts

I work on a project that has 2 branches, A and B. I typically work on branch A, and merge stuff from branch B. For the merging, I would typically do: git merge origin/branchB However, I would also like to keep a local copy of branch B, as I may…
charles
  • 9,897
  • 3
  • 28
  • 44
709
votes
10 answers

How to cherry pick a range of commits and merge into another branch?

I have the following repository layout: master branch (production) integration working What I want to achieve is to cherry pick a range of commits from the working branch and merge it into the integration branch. I pretty new to git and I can't…
crazybyte
  • 8,473
  • 5
  • 23
  • 21
649
votes
2 answers

Why does git perform fast-forward merges by default?

Coming from mercurial, I use branches to organize features. Naturally, I want to see this work-flow in my history as well. I started my new project using git and finished my first feature. When merging the feature, I realized git uses fast-forward,…
Florian Pilz
  • 7,692
  • 3
  • 20
  • 28
614
votes
9 answers

Please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch

I am using Git. I did a pull from a remote repo and got an error message: Please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch. I try to type a message and press…
bernie2436
  • 18,811
  • 41
  • 130
  • 228
539
votes
8 answers

What's the difference between 'git merge' and 'git rebase'?

What's the difference between git merge and git rebase?
Daniel Peñalba
  • 27,557
  • 31
  • 124
  • 209
519
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
  • 15,030
  • 6
  • 29
  • 34
481
votes
17 answers

The following untracked working tree files would be overwritten by merge, but I don't care

On my branch I had some files in .gitignore On a different branch those files are not. I want to merge the different branch into mine, and I don't care if those files are no longer ignored or not. Unfortunately I get this: The following untracked…
CQM
  • 36,672
  • 69
  • 214
  • 357
444
votes
5 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
  • 16,619
  • 14
  • 54
  • 62
431
votes
11 answers

How can I preview a merge in git?

I have a git branch (the mainline, for example) and I want to merge in another development branch. Or do I? In order to decide whether I really want to merge this branch in, i'd like to see some sort of preview of what the merge will do. Preferably…
Glenjamin
  • 6,375
  • 5
  • 22
  • 25
421
votes
5 answers

Merge up to a specific commit

I created a new branch named newbranch from the master branch in git. Now I have done some work and want to merge newbranch to master; however, I have made some extra changes to newbranch and I want to merge newbranch up to the fourth-from-the-last…
Dau
  • 7,478
  • 4
  • 21
  • 44
314
votes
11 answers

How do I finish the merge after resolving my merge conflicts?

I've read the Basic Branching and Merging section of the Git Community Book. So I follow it and create one branch: experimental. Then I: switch to experimental branch (git checkout experimental) make a bunch of changes commit it (git commit…
michael
  • 93,094
  • 111
  • 230
  • 334