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.

3320 questions
36 answers

How do I resolve merge conflicts in a Git repository?

How do I resolve merge conflicts in my Git repository?
  • 119,724
  • 44
  • 140
  • 158
35 answers

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 # Your branch is ahead of 'origin/master' by 5…
Matt Huggins
  • 81,398
  • 36
  • 149
  • 218
14 answers

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?
Gwyn Morfey
  • 32,741
  • 6
  • 25
  • 21
16 answers

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 several days and you want to continuously keep test…
  • 28,814
  • 4
  • 19
  • 16
20 answers

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?
  • 48,756
  • 50
  • 150
  • 175
19 answers

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, while keeping all conflict-free changes. Preferably,…
  • 29,083
  • 12
  • 64
  • 76
15 answers

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 messages In top repository we have to do one commit…
  • 28,934
  • 30
  • 90
  • 137
29 answers

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 exp1: experimental branch #1 exp2: experimental…
David Joyner
  • 22,449
  • 4
  • 28
  • 33
18 answers

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, but only merge other remaining files. So, I want…
  • 19,118
  • 13
  • 35
  • 31
11 answers

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" > file git commit -a -m "Initial commit" Feature1 branched…
  • 31,591
  • 21
  • 89
  • 127
15 answers

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 squash and then save-quit, but the rebase fails with the…
  • 106,540
  • 116
  • 246
  • 346
33 answers

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 following commands sometime before your next…
Davide Casiraghi
  • 15,591
  • 9
  • 34
  • 56
21 answers

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 ours. But what I want is something like git merge -s theirs. Why doesn't it…
  • 31,633
  • 21
  • 64
  • 68
11 answers

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 heard that Git is excellent for branching and merging,…
  • 17,584
  • 8
  • 40
  • 46
33 answers

.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 following: My-MacBook-Pro:webapp marcamillion$ git…
  • 32,933
  • 55
  • 189
  • 380
2 3
99 100