Server IP : 103.119.228.120 / Your IP : 3.135.209.107 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/doc/git-1.8.3.1/howto/ |
Upload File : |
Date: Sat, 5 Jan 2008 20:17:40 -0500 From: Sean <seanlkml@sympatico.ca> To: Miklos Vajna <vmiklos@frugalware.org> Cc: git@vger.kernel.org Subject: how to use git merge -s subtree? Abstract: In this article, Sean demonstrates how one can use the subtree merge strategy. Content-type: text/asciidoc Message-ID: <BAYC1-PASMTP12374B54BA370A1E1C6E78AE4E0@CEZ.ICE> How to use the subtree merge strategy ===================================== There are situations where you want to include contents in your project from an independently developed project. You can just pull from the other project as long as there are no conflicting paths. The problematic case is when there are conflicting files. Potential candidates are Makefiles and other standard filenames. You could merge these files but probably you do not want to. A better solution for this problem can be to merge the project as its own subdirectory. This is not supported by the 'recursive' merge strategy, so just pulling won't work. What you want is the 'subtree' merge strategy, which helps you in such a situation. In this example, let's say you have the repository at `/path/to/B` (but it can be a URL as well, if you want). You want to merge the 'master' branch of that repository to the `dir-B` subdirectory in your current branch. Here is the command sequence you need: ---------------- $ git remote add -f Bproject /path/to/B <1> $ git merge -s ours --no-commit Bproject/master <2> $ git read-tree --prefix=dir-B/ -u Bproject/master <3> $ git commit -m "Merge B project as our subdirectory" <4> $ git pull -s subtree Bproject master <5> ---------------- <1> name the other project "Bproject", and fetch. <2> prepare for the later step to record the result as a merge. <3> read "master" branch of Bproject to the subdirectory "dir-B". <4> record the merge result. <5> maintain the result with subsequent merges using "subtree" The first four commands are used for the initial merge, while the last one is to merge updates from 'B project'. Comparing 'subtree' merge with submodules ----------------------------------------- - The benefit of using subtree merge is that it requires less administrative burden from the users of your repository. It works with older (before Git v1.5.2) clients and you have the code right after clone. - However if you use submodules then you can choose not to transfer the submodule objects. This may be a problem with the subtree merge. - Also, in case you make changes to the other project, it is easier to submit changes if you just use submodules. Additional tips --------------- - If you made changes to the other project in your repository, they may want to merge from your project. This is possible using subtree -- it can shift up the paths in your tree and then they can merge only the relevant parts of your tree. - Please note that if the other project merges from you, then it will connect its history to yours, which can be something they don't want to.