Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how does git check if a merge is needed?

Tags:

git

git-merge

According to documentation, git update-index --refresh does this:

Looks at the current index and checks to see if merges or updates are needed by checking stat() information.

What does it mean that git "checks to see if merges or updates are needed"? Does git keep an arbitrary flag somewhere saying "mergeme" after certain operations?

Also, I think I understand stat ( what is "stat information" in a git index? ), but I don't see how knowing things like the UID help git at all know if a merge needs to happen.

like image 941
Alexander Bird Avatar asked Mar 16 '11 15:03

Alexander Bird


People also ask

How do you check if there will be a merge conflict?

To see the beginning of the merge conflict in your file, search the file for the conflict marker <<<<<<< . When you open the file in your text editor, you'll see the changes from the HEAD or base branch after the line <<<<<<< HEAD .

How will you know in git If a branch has not yet merged into master?

Step 3 − Check status of the merged and not merged branches from master using option --merged and --no-merged. The command and output are shown below. From the output it is clear that the branches bugfix and feature are to be merged to the master branch.


1 Answers

The description is a little misleading. This command check if the working copy has diverged from the index. In this context, a merge means that you'll need to use git add, git rm or git checkout to bring the index and the working copy in sync. This has nothing to do with git merge.

The index store a snapshot of the working copy file stat information in order to optimize the detection of modification by the user. It is updated every time those modification are inserted into the staging area (git add, git rm) or when the working copy modification are discarded (git checkout, git reset, ...).

like image 189
Sylvain Defresne Avatar answered Nov 05 '22 12:11

Sylvain Defresne