3

We have a project which was built using TFS as the source control. This has now been placed on GitHub.

We've also added a gh-pages branch on GitHub for the documentation.

However, we don't want the documentation files to clutter the main working directory.

How can I configure the local directory for gh-pages to be in a different location?

I've tried using git-new-workdir as found here, but Powershell told me

repository 'git@github.com/git/git.git' does not exist

I then tried cloning the Powershell script found here in place of the missing script from the previous example, but then I get the error message

[script path] not valid: is this a git repository?

Can someone please explain (in novice terms) how to map a branch to a different local directory?

[And for clarification, the local system is Windows, so available tools are GitHub for Windows and Powershell.]

awj
  • 7,482
  • 10
  • 66
  • 120
  • I think you are looking for "git submodules". – arkascha Jan 25 '15 at 11:15
  • I may have misunderstood the full ramifications of submodules, but that seems an overly complicated way of pointing to a different local folder. I also don't understand how it allows me to keep my existing branches separate - doesn't it apply to child directories rather than branches? – awj Jan 25 '15 at 11:21
  • OK. Then maybe I miss understood the question :-) If you just want to keep those files in a separate folder... then why don't you simply do so? and add that folder to git? If however your problem is that the folder should somehow not be part of git but still be part of it, well, then things _are_ somewhat more complicated. git submodules are very mich like svn ::externals. Not more, not less. you can use them to "pull in" stuff from external repositories. A good separation. – arkascha Jan 25 '15 at 11:23
  • Yes, I wish to keep the documentation in a separate folder, yet github-pages requires that you have a top-level `index.html` in the `gh-pages` branch. I don't want that page - or any others - in my working-code folder. I hope that explains why I want this `gh-pages` branch in a separate location. – awj Jan 25 '15 at 11:26
  • Why should that be a branch? A branch is a variant of the object, not something beside the object. I'd say you want to place them in a separate repository. but as said: maybe I missunderstand you. – arkascha Jan 25 '15 at 11:27
  • It has to be a branch because that's the way that github-pages works. https://pages.github.com/ - click on the option for "Project site" and you'll see the explanation that you should add a `gh-pages` branch. – awj Jan 25 '15 at 11:32
  • OK, then obviously I missunderstood their explanation at https://pages.github.com/ which states you create a repository, add pages and push them. Sorry. – arkascha Jan 25 '15 at 11:34
  • Those directions fairly clearly indicate that this should be a repository on its own. They even prescribe the **exact** name it must have. Nothing about that indicates a branch in a main repository. – Etan Reisner Jan 25 '15 at 11:42
  • > "Nothing about that indicates a branch in a main repository" Read the guide for the "Project site" option and it explains that a 'gh-pages' branch should be added. A separate repository *could* be an easy answer, but I'd rather keep the documentation exactly as GitHub suggests. – awj Jan 25 '15 at 11:45

2 Answers2

1

This can easily be solved by using 2 separate repositories. For example, projectname and projectname-docs.

By doing this, you can clone both repositories into completely separate folders as you desire.

I believe that this is the easiest (and likely only) way to do what you are asking using GitHub for Windows.


Alternatively, you could use command line git and clone the repository twice. You could use the first clone for your main working directory, and the second clone for gh-pages.

If this is something you are considering, you may want to have a look at this:

How to clone a specific Git branch?

Community
  • 1
  • 1
tehp
  • 5,018
  • 1
  • 24
  • 31
0

This is possible in Visual Studio 2022. I was working on my project which was 'cloned from github'. So the folder was different since it is cloned fresh. I was able to 'push it into a different branch' first by creating a branch 'master-2.0' and selecting the same in V.S.

habi
  • 125
  • 8