24

Problem occurs when codes are conflict.

VSCode merge resolution

As you see in image given above that four options are there

  1. Accept incoming changes
  2. Accept current changes
  3. Accept Both changes
  4. Compare changes

I want to know the difference between Accept Current changes and Accept Incoming changes

VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
saurabh Singh
  • 1,818
  • 2
  • 6
  • 11

2 Answers2

25

It depends on the type of operation (merge or rebase) leading to that conflict.

In your case, a merge, where:

  • current change represents what you have (the destination of the merge)
  • incoming change represents what you merge (the source of the merge)

Then:

  • Option 1 ("Accept Incoming changes") would ignore completely what you had, and keep what you merge.
  • Option 2 ("Accept current changes") would ignore completely what you merge, and keep what you had.

Don't forget, in case of a rebase, "what you have" and "what you merge" are reversed.

VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • 2
    So to make sure I understand: If I'm on BRANCH_1 and I run "git checkout master" and get conflicts: Incoming changes are what the file is like on master Current changes are what I did on BRANCH_1, correct? – Nick Tydryszewski Jul 29 '20 at 13:41
  • @NickTydryszewski Yes, provided you did a `git checkout -m master` (https://git-scm.com/docs/git-checkout#Documentation/git-checkout.txt--m) – VonC Jul 29 '20 at 14:25
  • @VonC "Option 1 (='Accept incoming changes') would ignore completely what you merge, and keep what you had." Is that true? My feeling tells me it's the opposite. – danzel Feb 03 '21 at 09:56
  • @danzel Agreed. I have edited the answer accordingly. – VonC Feb 03 '21 at 10:00
14

If it's a conflict due to a rebase, you could always imagine like so -

  1. Your master branch is fixed
  2. A feature branch that originated from an older commit on master, is shifting itself from there to the latest commit on master (that's what a rebase is, at its core).

Now, if you see from the point of view of master -

  • incoming changes are the ones that move to master (i.e. changes in your feature branch), hence the term.

  • current changes are the ones that are already present in master (i.e. ones done by fellow developers or yourself on master).

In case of merge conflicts, as suggested by @VonC, the terminology is reversed.

roshnet
  • 643
  • 9
  • 16
  • So, if I was on my feature branch and I ran `git pull --rebase origin master` Will `incoming changes` be the changes on master? – Mahmoud Tokura May 26 '21 at 19:47
  • 1
    @MahmoudTokura technically, yes. But in practice, we almost never merge master into our feature branch. – roshnet May 26 '21 at 21:13