Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

git merge branch not including all the file

Comparing the two branch tip commits is the wrong thing to do, because that's not what git merge does.

To see what files each of you changed, you must first find the commit that branches A and B most recently shared:

             o--o   <-- branch-B
            /
...--o--o--*
            
             o--o--o   <-- branch-A
(where each round o represents a commit, in the chain of commits people have added over time).

The common commit, which I marked * here, is what Git calls the merge base of the two branches. Git will find this commit automatically, on its own, when you sit at the tip of one of the two branches (such as B) and run git merge A.

Git will then compare, not B vs A, nor A vs B, but rather:

git diff hash-of-* hash-of-tip-of-B    # what did *we* change?
and:

git diff hash-of-* hash-of-tip-of-A    # what did *they* change?
The goal of git merge is to locate and extract commit *, apply all the changes from both branches, and commit that as a new merge commit on the current branch (B), with two parent commits, to make it a merge commit so that Git knows what to use as the merge base the next time too.

If you want to see the hash ID of commit *, you can run git merge-base:

git merge-base --all A B
You can then run git diff, giving it that hash ID for the merge base, and the name A to select the tip of branch A to see what they changed. You can run a second, separate, git diff, giving it that same hash ID for the merge base, and the name B to select the tip of branch B to see what you changed (you might remember what you changed, but it's a good idea to see if Git agrees with your memory, because Git is going to use what it finds, not what you remember!).

There is a short-hand that will run git merge-base for you, that works only with git diff:

git diff A...B   # note the three dots
will compare the merge base of A and B against the commit identified by B, to find what you changed. A subsequent:

git diff B...A   # note the three dots again
will compare the merge base of B and A1 against the commit identified by A, to find what they changed.

(You can add options like --name-status or --name-only to the git diff to affect how git diff shows the changes it calculates / finds. Note that whenever there are renames involved, the merge uses the equivalent of git diff -M50 to find the renames. Modern Git, since 2.9, enables rename detection in git diff as well by default.)
Comment

PREVIOUS NEXT
Code Example
Shell :: kill process based on username windows 
Shell :: column cut linux 
Shell :: Initialize Git repository with different name 
Shell :: export VARs into you local env 
Shell :: Error getting SSL certificate "default/tls-secret": local SSL certificate default/tls-secret was not found. Using default certificate 
Shell :: change mode type cursor 
Shell :: killall kinsing 
Shell :: see what is through an archive 
Shell :: save admin credentials for program 
Shell :: sort specific extension by date 
Shell :: The last character of the "bash" prompt is usually 
Shell :: ring check if the operating system is Linux or not 
Shell :: format volume diskpart 
Shell :: grub bootloader corrupted fedora 36 
Shell :: install rar, unrar on fedora 
Shell :: linux move to trash command line 
Shell :: grub rescue commands linux 
Shell :: instsall typo3 
Shell :: batch rename folders & trim spaces & add prefix / suffix 
Shell :: ignore all logs 
Shell :: metasploit msf commands kali linux 
Shell :: install react-livechat 
Shell :: qemu convert qcow2 to vhd 
Shell :: watch bash second 
Shell :: linux maximize window 
Shell :: awk match last occurrence 
Shell :: how to capture notification in linux 
Shell :: shared folder in vmware workstation 15 rhel 8 
Shell :: lint check oppia 
Shell :: how to close terminal 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =