Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: put a branch in a subdirectory

Tags:

I have a git repository (at github.com) with two branches: master and gh-pages. I would like to have the gh-pages branch in a subdirectory, so that I don't need to switch branches every time.

repo/     (content of the master branch)     gh-pages/             (content of the gh-pages branch) 

Is that possible ?

like image 612
Giovanni Funchal Avatar asked Mar 05 '10 12:03

Giovanni Funchal


People also ask

How do you create a branch within a folder?

In Source Control Explorer, right-click the folder or file that you want to branch, point to Branching and Merging, and then click Branch.

Can we create a sub branch in git?

Git doesn't really have a concept of sub-branches. Right now, all of your branches will show up in that dropdown if they have been pushed up to Bitbucket. Yes, It is possible to create a sub-branch in bitbucket.

Does git add add subdirectories?

It will add all the Folders , Subfolders and files to the existing repo.

What is subdirectory in git?

But if we add the -a flag to show everything, we can see that Git has created a hidden directory within planets called .git : $ ls -a. . .. . git. Git uses this special subdirectory to store all the information about the project, including the tracked files and sub-directories located within the project's directory.


1 Answers

You may be looking for the subtree merging option.

It will let you checkout an unrelated branch into a subdirectory of another and then merge back and forth between them. You would still have to checkout gh-pages and merge in changes from the main repo before pushes would go live on GitHub, however.

You could also check gh-pages out as a submodule of your master branch if that suits you better.

like image 123
Scott Chacon Avatar answered Oct 30 '22 19:10

Scott Chacon