GitHub: Difference between Accept current changes and Incoming changes

Github

Github Problem Overview


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

Github Solutions


Solution 1 - Github

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.

Solution 2 - Github

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.

Solution 3 - Github

You are on a feature branch

1. git pull origin master
Current changes

Changes on your current feature branch.

Incoming changes

Changes you are pulling from i.e the master branch


2. git pull origin master --rebase

During rebase your feature branch changes are applied on top of the commits that are already there in master branch.

Current changes

Changes on the master branch.

Incoming changes

Changes on the feature branch.


* After a rebase, you need to force push your branch. Use --force-with-lease instead of --force

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionsaurabh SinghView Question on Stackoverflow
Solution 1 - GithubVonCView Answer on Stackoverflow
Solution 2 - GithubroshnetView Answer on Stackoverflow
Solution 3 - GithubBadal SaiboView Answer on Stackoverflow