-3

In a Git repository, I need to change the path of the "master" branch to a subfolder instead of the root folder (default).

Example:

/ -> contains some config files, could be the "sources" branch

/master/ -> contains the files of the "master" branch

Is this possible? How can I do it?

More precisions:

Usually I use Github pages feature, so I use the "worktree" feature to set the "gh-pages" branch in a subfolder. With Hugo, this is in "/public". See Hugo's documentation for details:
https://gohugo.io/tutorials/github-pages-blog/

Git's worktree feature:
https://git-scm.com/docs/git-worktree

However, on one of the server, generated files must be in /, in "master". So if I still want to have Hugo source files in the same repositories, I need to have them in an other folder and/or branch.

ttoine
  • 192
  • 1
  • 12
  • 3
    So you basically just want to move some tracked files in your repository under branch master? If that's not the case (I'm not sure actually, your post is unclear to me) maybe you could add some precisions. – vmonteco Jul 06 '17 at 11:16
  • Slightly ambiguous description, I interpret this as you either want to do what @vmonteco suggests, or you're looking to alter the branch naming structure so you have `/` and `/master/`? – Chris Jul 06 '17 at 11:22
  • This question is very unclear. Branches don't have paths. They're pointers within a repository. I sounds like you want to remove files from your repository. Just delete them? – Liam Jul 06 '17 at 11:41
  • Possible duplicate of [Multiple working directories with Git?](https://stackoverflow.com/questions/6270193/multiple-working-directories-with-git) – Whymarrh Jul 06 '17 at 11:44
  • I added details. I usually use git's worktree feature for that. But it seems that only a few developers know it... And in this case, I would like to have a specific setting that is not well documented. – ttoine Jul 06 '17 at 13:31

2 Answers2

1

A Git branch is a pointer to a commit. A Git commit contains the status of the entire project at some moment in time. At most one branch can be active and it brings all the project to the state of the project when the commit it points to was created.

It is possible to checkout the config files from the "sources" branch while the "master" branch is the current branch but this only changes the content of the checked out files in the working tree. Those files will probably be reported as "Changed" by git status; the changes will, however, be committed to the current branch ("master").

It is not possible to get what you described in the question.

Or, maybe, the question doesn't express correctly what you need.

axiac
  • 68,258
  • 9
  • 99
  • 134
  • Using Git's worktree feature, I usually have the sources in "master" on /, and the generated files in /public/ goes to the "gh-pages" branch. And I use a .gitignore, so master ignore the content of /public/. This is very easy. But in this very special case (not a Github git repo) I need to have the generated files in "master" and /. – ttoine Jul 06 '17 at 13:26
0

After reading an other question of yours (it looks like you didn't find your answer in the previous one so you're asking again), it looks like you'd like to store different parts of your project in different branches (adding your Hugo configuration to an other branch).

Usually, a whole projet is splitted in different directories or repositories rather than branches. Why wouldn't you do that?

You could have a project with the following tree :

.
├── .git
├── conf
└── src

Splitting in branches sounds unusual to me and probably isn't a so good idea.

vmonteco
  • 14,136
  • 15
  • 55
  • 86
  • With Github, you can set the "gh-pages" branch in a subfolder, using git's "worktree" feature. (https://gohugo.io/tutorials/github-pages-blog/) However, here, I must have a specific set of files in /, and in "master" so a hook can handle them. – ttoine Jul 06 '17 at 13:16