Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub: Difference between Accept current changes and Incoming changes

Tags:

github

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

like image 705
saurabh Singh Avatar asked Jan 06 '20 06:01

saurabh Singh


People also ask

How do I accept incoming changes in Github?

Git : accept all incoming changes In the case that you wish accept all incoming changes in the branch, you can cd to the repository and run git against the current directory. (awesome-new-feature) git checkout --theirs .

What is accept both changes in git?

The only way to "accept both" would be to just re-stage (marking as resolved) the conflicted files without resolving them ( >>> and <<< would be there still), but your result couldnt be compiled or executed. And this is terrible practice, even if you make commits later to resolve.

How do I accept all incoming changes or codes?

Its very easy just go to vs code and press Ctrl + shift + p (command palette) or go to view and open command palette manually and type "merge" in your command palette, now you can see the Accept all current changes.

What is merge incoming changes into the current branch?

Merge the incoming changes into the current branch: select this option to perform merge during the update. This is equivalent to running git fetch and then git merge , or git pull --no-rebase . Rebase the current branch on top of the incoming changes: select this option to perform rebase during the update.


2 Answers

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.

like image 200
VonC Avatar answered Sep 17 '22 11:09

VonC


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.

like image 44
roshnet Avatar answered Sep 17 '22 11:09

roshnet