Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git read-tree to project root

Tags:

git

merge

I have my main_repo with folder structure like this

application_root

  • app
    • code
      • foo
        • file1
        • file2
      • bar
  • skin
  • lib
  • file1
  • file2

It's the main application. And I have another repo with an extension for my main application. The problem is that extension directory layout overlap directories from the root of main project such as

extension_root

  • app
    • code
      • baz
        • file1
        • file2
  • skin
    • file1
    • file2
  • file3
  • file4

So I can't use submodule tool. I need to merge this two repositories for farther development. I need the ability to merge from extension_repo to main_repo and back as well so if I made changes to my extension which was merged to main_repo I can merge only this changes (without application itself) to extension_repo. I don't know if it even possible. It seems that read-tree merging do what I want but I can't use it in such way

git read-tree --prefix=/ -u extension_remote_branch

because I get this error

error: Entry '.gitignore' overlaps with '.gitignore'.  Cannot bind.

I guess I'll get this error for all directories I have overlaped. I don't actually have overlaped files except of .gitignore.

like image 590
krasilich Avatar asked Aug 02 '12 12:08

krasilich


People also ask

What does git read tree do?

Usually a three-way merge by git read-tree resolves the merge for really trivial cases and leaves other cases unresolved in the index, so that porcelains can implement different merge policies.

What does git merge command do?

Git merge will combine multiple sequences of commits into one unified history. In the most frequent use cases, git merge is used to combine two branches.

Which command is used for creating tree object in git?

Tree Objects When using PowerShell, parameters using {} characters have to be quoted to avoid the parameter being parsed incorrectly: git cat-file -p 'master^{tree}' . If you're using ZSH, the ^ character is used for globbing, so you have to enclose the whole expression in quotes: git cat-file -p "master^{tree}" .


1 Answers

So far I haven't found a way to do this in a single command via git; so instead I use a fairly straightforward workaround. The basic approach is to read-tree into a second, empty directory. Then move the second directory overtop the first.

The basic flow is:

mkdir upstream-tree
git read-tree --prefix=upstream-tree/ -u myremote/branch
git commit -m "Pulled in remote tree"
cp -rf upstream-tree/* local-tree/
git rm -r upstream-tree
git add local-tree
git commit -m "Merged upstream-tree into local-tree"
like image 157
STW Avatar answered Sep 30 '22 21:09

STW