EGit not-for-merge

I cloned my new repo from Github and the FETCH_HEAD file in the working directory → .git contains the following:

fe300b2c9852acf68b4f1dd78ace916a083f3236 not-for-merge branch 'master' of ssh:// git@github.com /mike123/myRepo.git 

What does not mean to merge?

+4
source share
2 answers

Basically, git fetch fetches the branches and saves the result in the FETCH_HEAD file. When it starts as part of git pull , this information is later used internally to decide what needs to be combined.

In the case of selecting multiple branches, only those that are not marked as not-for-merge are merged later. See also this blog post by Junio.

In your case, JGit (the library used by EGit to work with Git repositories) seems to behave differently than the Git command line implementation. There is no FETCH_HEAD Git command line after cloning. But after the first time you pull, the file is there. Try pulling and see how the file changes. This difference in implementation should not cause any harm.

0
source

Egit is based on JGit, and " not-for-merge " is used only in org.eclipse.jgit.transport.FetchHeadRecord

This notForMerge variable of the notForMerge parameter is set in the org.eclipse.jgit.transport.FetchProcess#want method.

  fhr.notForMerge = spec.getDestination() != null; 

If the endpoint of refspec is not NULL, then this selected HEAD is not for merging.

When you select remote access, the destination of the remote branches is refs/remotes/yourRemote , due to the local configuration for fetch refspec:

 [remote "origin"] fetch +refs/heads/*:refs/remotes/origin/* 

The only branch that will be selected without a direct destination will be the one that tracks the remote branch:

 [branch "master"] remote = origin merge = refs/heads/master 

This is why after receiving the JGit repo (on the command line, not in Eclipse Egit), I see:

 C:\Users\VonC\prog\git\jgit\.git>type FETCH_HEAD c2a9f9e742f7e6633af130823c154a485e6071b2 branch 'master' of https://github.com/eclipse/jgit 51d1af9489924ff03fa10ec963110c608c2882a3 not-for-merge branch 'stable-0.10' of https://github.com/eclipse/jgit 989149736ad1cd09c15e143aa598028b9f9b6502 not-for-merge branch 'stable-0.11' of https://github.com/eclipse/jgit b2b58feba7400269df8b31ef8495b695af3a9793 not-for-merge branch 'stable-0.12' of https://github.com/eclipse/jgit 

Try reproducing this in Egit / JGit (Luna, Egit 3.0, Win7 64-bit):

After several selections, I never see a record without not-for-merge . Even an attraction that would merge new commits from the remote branch would still create FETCH_HEAD with:

 220c4502ecea147ef4beaae8039b168965e148e9 not-for-merge branch 'master' of ..\..\jgit 

I assume that the behavior of JGit is different in this aspect.

0
source

Source: https://habr.com/ru/post/1497336/


All Articles