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
5011
votes
38 answers

How to resolve merge conflicts in Git repository?

I want to resolve merge conflicts in my Git repository. How to do that ?
Spoike
  • 112,352
  • 42
  • 133
  • 155
4283
votes
33 answers

Undo a Git merge that hasn't been pushed yet

Within my master branch, I did a git merge some-other-branch locally, but never pushed the changes to origin master. I didn't mean to merge, so I'd like to undo it. When doing a git status after my merge, I was getting this message: # On branch…
Matt Huggins
  • 73,807
  • 32
  • 140
  • 214
2795
votes
13 answers

I ran into a merge conflict. How can I abort the merge?

I used git pull and had a merge conflict: unmerged: _widget.html.erb You are in the middle of a conflicted merge. I know that the other version of the file is good and that mine is bad so all my changes should be abandoned. How can I do this?
Gwyn Morfey
  • 29,133
  • 6
  • 23
  • 21
2325
votes
14 answers

What is the best (and safest) way to 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…
moe
  • 25,936
  • 3
  • 17
  • 16
1698
votes
17 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?
Coocoo4Cocoa
  • 41,896
  • 50
  • 148
  • 175
1546
votes
26 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
  • 19,979
  • 4
  • 25
  • 33
1508
votes
12 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 ? Basically I need to remove all conflicting changes from a working tree without having to go through all of the conflicts with a git mergetool while keeping all conflict-free changes.…
sanmai
  • 23,569
  • 11
  • 54
  • 73
1420
votes
15 answers

How to use git merge --squash?

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…
SunnyShah
  • 24,498
  • 28
  • 81
  • 130
1261
votes
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…
theomega
  • 29,902
  • 21
  • 83
  • 125
1230
votes
13 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…
michael
  • 93,094
  • 111
  • 230
  • 334
1138
votes
12 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…
seg.server.fault
  • 15,608
  • 12
  • 32
  • 31
1007
votes
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,…
Micah
  • 16,906
  • 7
  • 38
  • 46
973
votes
18 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…
elmarco
  • 27,816
  • 21
  • 58
  • 68
883
votes
29 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…
marcamillion
  • 29,563
  • 49
  • 161
  • 337
854
votes
6 answers

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 while merging. Now I want do discard everything…
Anshul
  • 8,541
  • 3
  • 13
  • 4
1
2 3
99 100