Alexander Bird
Alexander Bird

Reputation: 40619

how does git check if a merge is needed?

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.

Upvotes: 8

Views: 444

Answers (1)

Sylvain Defresne
Sylvain Defresne

Reputation: 44503

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, ...).

Upvotes: 2

Related Questions