Skip to content

Instantly share code, notes, and snippets.

@carlosveigadev
Forked from cobyism/gh-pages-deploy.md
Created January 15, 2021 15:11
Show Gist options
  • Save carlosveigadev/84ba8b8e6adca79068d036d750cc87f7 to your computer and use it in GitHub Desktop.
Save carlosveigadev/84ba8b8e6adca79068d036d750cc87f7 to your computer and use it in GitHub Desktop.

Revisions

  1. Coby Chapple revised this gist Mar 4, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gh-pages-deploy.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Deploying a specific folder to GitHub Pages
    # Deploying a subfolder to GitHub Pages

    Sometimes you want to have a subdirectory on the `master` branch be the root directory of a repository’s `gh-pages` branch. This is useful for things like sites developed with [Yeoman](http://yeoman.io), or if you have a Jekyll site contained in the `master` branch alongside the rest of your code.

  2. Coby Chapple revised this gist Mar 4, 2014. 2 changed files with 47 additions and 26 deletions.
    47 changes: 47 additions & 0 deletions gh-pages-deploy.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    # Deploying a specific folder to GitHub Pages

    Sometimes you want to have a subdirectory on the `master` branch be the root directory of a repository’s `gh-pages` branch. This is useful for things like sites developed with [Yeoman](http://yeoman.io), or if you have a Jekyll site contained in the `master` branch alongside the rest of your code.

    For the sake of this example, let’s pretend the subfolder containing your site is named `dist`.

    ### Step 1

    Remove the `dist` directory from the project’s `.gitignore` file (it’s ignored by default by Yeoman).

    ### Step 2

    Make sure git knows about your subtree (the subfolder with your site).

    ```sh
    git add dist && git commit -m "Initial dist subtree commit"
    ```

    ### Step 3

    Use subtree push to send it to the `gh-pages` branch on GitHub.

    ```sh
    git subtree push --prefix dist origin gh-pages
    ```

    Boom. If your folder isn’t called `dist`, then you’ll need to change that in each of the commands above.

    ---

    If you do this on a regular basis, you could also [create a script](https://github.com/cobyism/dotfiles/blob/master/bin/git-gh-deploy) containing the following somewhere in your path:

    ```sh
    #!/bin/sh
    if [ -z "$1" ]
    then
    echo "Which folder do you want to deploy to GitHub Pages?"
    exit 1
    fi
    git subtree push --prefix $1 origin gh-pages
    ```

    Which lets you type commands like:

    ```sh
    git gh-deploy path/to/your/site
    ```
    26 changes: 0 additions & 26 deletions gh-pages-dist-deploy.md
    Original file line number Diff line number Diff line change
    @@ -1,26 +0,0 @@
    # Deploying a dist folder to GitHub Pages

    Sometimes you want to have a subdirectory on the `master` branch be the root directory of a repository’s `gh-pages` branch. This is useful for things like sites developed with [Yeoman](http://yeoman.io).

    ### Step 1

    Remove the `dist` directory from the project’s `.gitignore` file (it’s ignored by default by yeoman).

    ### Step 2

    Set up the subtree.

    ```sh
    git add dist && git commit -m "Initial dist subtree commit"
    git subtree push --prefix dist origin gh-pages
    ```

    ### Step 3

    Deploy dat subtree.

    ```sh
    git subtree push --prefix dist origin gh-pages
    ```

    Boom. If your folder isn’t called `dist`, then you’ll need to change that in each of the commands above.
  3. Coby Chapple revised this gist Feb 7, 2013. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions gh-pages-dist-deploy.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ Sometimes you want to have a subdirectory on the `master` branch be the root dir

    ### Step 1

    Remove the `dist` directory from the project’s `.gitignore` file.
    Remove the `dist` directory from the project’s `.gitignore` file (it’s ignored by default by yeoman).

    ### Step 2

    @@ -22,6 +22,5 @@ Deploy dat subtree.
    ```sh
    git subtree push --prefix dist origin gh-pages
    ```
    ---

    Boom.
    Boom. If your folder isn’t called `dist`, then you’ll need to change that in each of the commands above.
  4. Coby Chapple revised this gist Feb 7, 2013. 1 changed file with 21 additions and 3 deletions.
    24 changes: 21 additions & 3 deletions gh-pages-dist-deploy.md
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,26 @@

    Sometimes you want to have a subdirectory on the `master` branch be the root directory of a repository’s `gh-pages` branch. This is useful for things like sites developed with [Yeoman](http://yeoman.io).

    1. Remove the `dist` directory from the project’s `.gitignore` file.
    2. Run the script below called `setup.sh` to set up the subtree.
    3. Run the script below called `deploy.sh` to deploy the subtree to GitHub Pages.
    ### Step 1

    Remove the `dist` directory from the project’s `.gitignore` file.

    ### Step 2

    Set up the subtree.

    ```sh
    git add dist && git commit -m "Initial dist subtree commit"
    git subtree push --prefix dist origin gh-pages
    ```

    ### Step 3

    Deploy dat subtree.

    ```sh
    git subtree push --prefix dist origin gh-pages
    ```
    ---

    Boom.
  5. Coby Chapple revised this gist Feb 7, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gh-pages-dist-deploy.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    # Deploying a dist folder to GitHub Pages

    Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s `gh-pages` branch. This is useful for things like sites developed with [Yeoman](http://yeoman.io).
    Sometimes you want to have a subdirectory on the `master` branch be the root directory of a repository’s `gh-pages` branch. This is useful for things like sites developed with [Yeoman](http://yeoman.io).

    1. Remove the `dist` directory from the project’s `.gitignore` file.
    2. Run the script below called `setup.sh` to set up the subtree.
    3. Run the script below called `deploy.sh` to deploy the subtree to GitHub Pages.

    :boom:
    Boom.
  6. Coby Chapple created this gist Feb 7, 2013.
    9 changes: 9 additions & 0 deletions gh-pages-dist-deploy.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    # Deploying a dist folder to GitHub Pages

    Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s `gh-pages` branch. This is useful for things like sites developed with [Yeoman](http://yeoman.io).

    1. Remove the `dist` directory from the project’s `.gitignore` file.
    2. Run the script below called `setup.sh` to set up the subtree.
    3. Run the script below called `deploy.sh` to deploy the subtree to GitHub Pages.

    :boom: