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.
git-merge
3,404
questions
5387
votes
36
answers
3.6m
views
How do I resolve merge conflicts in a Git repository?
How do I resolve merge conflicts in my Git repository?
4902
votes
35
answers
3.3m
views
Undo a Git merge that hasn't been pushed yet
I accidentally ran git merge some_other_branch on my local master branch. I haven't pushed the changes to origin master. How do I undo the merge?
After merging, git status says:
# On branch master
# ...
3208
votes
14
answers
2.6m
views
I ran into a merge conflict. How do I abort the merge?
I used git pull and had a merge conflict:
unmerged: some_file.txt
You are in the middle of a conflicted merge.
How do I abandon my changes to the file and keep only the pulled changes?
2653
votes
17
answers
2.2m
views
How do I safely merge a Git branch into master?
A new branch from master is created, we call it test.
There are several developers who either commit to master or create other branches and later merge into master.
Let's say work on test is taking ...
2413
votes
19
answers
984k
views
When do you use Git rebase instead of Git merge?
When is it recommended to use Git rebase vs. Git merge?
Do I still need to merge after a successful rebase?
2055
votes
19
answers
1.6m
views
Resolve Git merge conflicts in favor of their changes during a pull
How do I resolve a git merge conflict in favor of pulled changes?
I want to remove all conflicting changes from a working tree without having to go through all of the conflicts with git mergetool, ...
1891
votes
15
answers
1.1m
views
How can I merge multiple commits onto another branch as a single squashed commit?
I have a remote Git server, here is the scenario which I want to perform:
For each bug/feature I create a different Git branch
I keep on committing my code in that Git branch with un-official Git ...
1818
votes
29
answers
1.2m
views
How can I selectively merge or pick changes from another branch in Git?
I'm using Git on a new project that has two parallel -- but currently experimental -- development branches:
master: import of existing codebase plus a few modifications that I'm generally sure of
...
1465
votes
19
answers
1.9m
views
Undo git pull, how to bring repos to old state
Is there any way to revert or undo git pull so that my source/repos will come to old state that was before doing git pull ?
I want to do this because it merged some files which I didn't want to do so, ...
1378
votes
15
answers
1.2m
views
How can I merge two commits into one if I already started rebase?
I am trying to merge 2 commits into 1, so I followed “squashing commits with rebase” from git ready.
I ran
git rebase --interactive HEAD~2
In the resulting editor, I change pick to ...
1355
votes
11
answers
1.9m
views
Git merge hotfix branch into feature branch
Let’s say we have the following situation in Git:
A created repository:
mkdir GitTest2
cd GitTest2
git init
Some modifications in the master take place and get committed:
echo "On Master" > ...
1351
votes
35
answers
1.7m
views
How can I deal with this Git warning? "Pulling without specifying how to reconcile divergent branches is discouraged"
After a git pull origin master, I get the following message:
warning: Pulling without specifying how to reconcile divergent branches is
discouraged. You can squelch this message by running one of the ...
1135
votes
21
answers
714k
views
Is there a "theirs" version of "git merge -s ours"?
When merging topic branch "B" into "A" using git merge, I get some conflicts. I know all the conflicts can be solved using the version in "B".
I am aware of git merge -s ...
1042
votes
11
answers
231k
views
Git workflow and rebase vs merge questions
I've been using Git now for a couple of months on a project with one other developer. I have several years of experience with SVN, so I guess I bring a lot of baggage to the relationship.
I have ...
1041
votes
33
answers
1.6m
views
.gitignore and "The following untracked working tree files would be overwritten by checkout"
So I added a folder to my .gitignore file.
Once I do a git status it tells me
# On branch latest
nothing to commit (working directory clean)
However, when I try to change branches I get the ...
1018
votes
21
answers
320k
views
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.
1010
votes
15
answers
1.3m
views
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 ...
993
votes
7
answers
638k
views
How to undo a git merge with conflicts
I am on branch mybranch1. mybranch2 is forked from mybranch1 and changes were made in mybranch2.
Then, while on mybranch1, I have done git merge --no-commit mybranch2
It shows there were conflicts ...
948
votes
15
answers
1.1m
views
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 ...
945
votes
24
answers
654k
views
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 ...
893
votes
12
answers
577k
views
How to cherry-pick a range of commits and merge them 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 ...
875
votes
20
answers
237k
views
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 ...
865
votes
10
answers
1.0m
views
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 ...
779
votes
21
answers
1.3m
views
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.
...
670
votes
2
answers
167k
views
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 ...
666
votes
8
answers
305k
views
What's the difference between 'git merge' and 'git rebase'?
What's the difference between git merge and git rebase?
600
votes
7
answers
432k
views
How to "git merge" without creating a merge commit?
Is it possible to do a git merge, but without a commit?
"man git merge" says this:
With --no-commit perform the merge but pretend the merge failed and do not autocommit,
to give the user a chance to ...
588
votes
17
answers
276k
views
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 ...
539
votes
6
answers
255k
views
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 ...
510
votes
12
answers
189k
views
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 ...
465
votes
4
answers
156k
views
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-...
427
votes
12
answers
625k
views
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)
...
412
votes
8
answers
600k
views
How to keep a branch synchronized/updated with master?
At the moment git is doing my head in, I cannot come up with the best solution for the following.
There are two branches, one called master and one called mobiledevicesupport. I want to keep ...
396
votes
14
answers
389k
views
How do I 'overwrite', rather than 'merge', a branch on another branch in Git?
I have two branches, email and staging. staging is the latest one and I no longer need the old changes in email branch, yet I don't want to delete them.
So I just want to dump all the contents of ...
359
votes
8
answers
542k
views
Git merge errors
I have a git branch called 9-sign-in-out with perfectly working code, and I want to turn it into the master. I'm currently on the master branch.
$ git branch
9-sign-in-out
* master
I'm trying to ...
352
votes
22
answers
426k
views
Git error on commit after merge - fatal: cannot do a partial commit during a merge
I ran a git pull that ended in a conflict. I resolved the conflict and everything is fine now (I used mergetool also).
When I commit the resolved file with git commit file.php -m "message" I get the ...
351
votes
9
answers
203k
views
Re-doing a reverted merge in Git
I have run into a bit of a problem here: I had a problem-specific branch 28s in Git, that I merged in the general develop branch. Turns out I had done it too fast, so I used git-revert to undo the ...
336
votes
4
answers
90k
views
Find unmerged Git branches?
I have a Git repository with many branches, some of them already merged and some not. Since the number of branches is quite large, how can I determine which branches have not yet been merged? I would ...
312
votes
16
answers
282k
views
How to merge specific files from Git branches
I have 2 git branches:
branch1
branch2
I want to merge all the history (multiple commits) of file.py in branch2 into file.py in branch1 and only that file.
In essence I just want to work on the file....
290
votes
5
answers
314k
views
How do I fix a merge conflict due to removal of a file in a branch?
I have create a dialog branch and when I try to merge it to master branch. There are 2 conflicts. I don't know how to resolve CONFLICT (delete/modify). Can you please tell me what to do?
$ git ...
285
votes
8
answers
252k
views
How can I configure KDiff3 as a merge tool and diff tool for git?
Recently I was using GitExtension 2.46, but the Git version that has the same is 1.9.4.msysgit.2. Willing to use only Git commands, I uninstalled GitExtension and install the latest version available ...
281
votes
4
answers
449k
views
Abort a Git Merge
I am working on a project using Git as the VCS. I got a branch xyz cut from the mainline branch of master. After working for a while, I committed my code and took a pull of the branch mainline.
The ...
280
votes
10
answers
221k
views
Merge stashed change with current changes
I made some changes to my branch and realized I forgot I had stashed some other necessary changes to the said branch. What I want is a way to merge my stashed changes with the current changes.
Is ...
274
votes
1
answer
71k
views
Restart/undo conflict resolution in a single file
In a larger git merge with several conflicting files, I incorrectly marked a file as resolved (using git add FILE after some editing)
Now I'd like to undo my conflict resolution attempt and start ...
262
votes
6
answers
279k
views
How do I merge a git tag onto a branch
I'm trying to find the syntax for merging a tagged commit onto another branch. I guess it's straightforward but my feeble search attempts aren't finding it.
255
votes
7
answers
439k
views
Is it possible to pull just one file in Git?
I am working on a Git branch that has some broken tests, and I would like to pull (merge changes, not just overwrite) these tests from another branch where they are already fixed.
I know I can do
...
252
votes
8
answers
370k
views
Git merge error "commit is not possible because you have unmerged files"
I forgot to git pull my code before editing it; when I committed the new code and tried to push, I got the error "push is not possible".
At that point I did a git pull which made some files ...
251
votes
8
answers
93k
views
git - skipping specific commits when merging
I've been using Git for about a year now and think it's fantastic, but I've just started on a second version of the project and started a new branch for it. I'm struggling a little with the best way ...
247
votes
3
answers
120k
views
How do I use vimdiff to resolve a git merge conflict?
I just merged a branch into my master in git and I got Automatic merge failed; fix conflicts and then commit the result. Now I ran git mergetool and vimdiff opened with the image below. I don't know ...
246
votes
2
answers
54k
views
How does git merge after cherry-pick work?
Let's imagine that we have a master branch.
Then we create a newbranch
git checkout -b newbranch
and make two new commits to newbranch: commit1 and commit2
Then we switch to master and make cherry-...