4

I have a branch that has the content of the master branch as a subdirectory. Now I made some changes to this subdirectory. Ideally I want to be able to merge these changes back into the master branch.

Branch layout:

index.html
subdirectory
  > a.txt
  > b.txt

Master layout

a.txt
b.txt

How would I go about doing this? Is it even a good approach? In SVN I avoided merging subdirectories back into the trunk. But this is a somewhat different use case, the layout of both, the branch and master, will never change.

mmmmmm
  • 32,227
  • 27
  • 88
  • 117
oschrenk
  • 4,080
  • 4
  • 22
  • 25
  • How did your branch get into that state in the first place? The root of your feature branch should always be the root of your master branch. – Jimmy Feb 25 '10 at 23:31
  • I know. I need this structure for my Github project page. The master branch reflects the current development branch of a small web application. Github supports delivery of html pages (and css,...) if they exist in a branch called gh-pages. The index.html is the welcome page, where you find general infos about the project, whereas the subdirectoy contains the iphone webapplication. – oschrenk Feb 27 '10 at 14:08
  • @Jimmy: just for information, the OP oschrenk just answered your question about "How did your branch get into that state in the first place". – VonC Feb 27 '10 at 14:26
  • see http://blog.stackoverflow.com/2010/01/new-improved-comments-with-reply (section "Comment @username Notifications"): if your comment doesn't begin with @Jimmy, he won't notice your answer (unless he actually revisit this question) – VonC Feb 27 '10 at 14:27
  • @VonC Thanks for the heads up (and for notifying Jimmy Cuadra). First time arround. – oschrenk Feb 28 '10 at 19:31

2 Answers2

1

You could try

  • making a branch from your current branch (git branch to_be_merge_to_master)
  • moving back your file to the correct structure (git mv ...)
  • merging that second branch to master
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @VonC while this is a solution, it would be cool if you could directly merge a sub-directory of a given branch. i have the same need as the author or this question, due to the way gh-pages work. – alex Sep 21 '12 at 17:25
  • @alex then the approach in https://gist.github.com/833223 ("Setup GitHub Pages "gh-pages" branch and "master" branch as subfolders of a parent project folder ("grandmaster")."), initially presented in http://stackoverflow.com/a/4993758/6309 can be interesting. – VonC Sep 21 '12 at 17:48
1

make use of git submodules

knittl
  • 246,190
  • 53
  • 318
  • 364
  • This seems like the way to go in the long run. In case of the Github project page I would need a separate project to display the application(s). Maybe I move them to my user page. – oschrenk Feb 27 '10 at 14:17