I have a repository in github which will house all of my web development assignments in separate sub-folders like :
VishnuVelukutty/ CourseraWebdevAssignment (master)/ module2-assignment (subfolder)
So the master branch has gh-pages and I want to add the gh-page to all sub-folders (Assignment1,2,3 .....) independently so that they work independently when the specific module-link is opened
Is it possible to apply gh-pages to a subfolder ? or do I have create independent repo for each module ?
I have not initiated .gitignore, static site, readme nor theme and reffered to this post by cobyism and chrisjacob but i didn't get it working
Here is my github account to see if there any errors in setting up
For reference of the images here is the git link
First, make sure to create a gh-pages branch, add at least one commit in it and push it to your GitHub repository.
Then, yes, you can add that gh-pages branch content as a subfolder of your current repository, in the master branch, using git submodule.
(unless, as explained here, you chose the master branch itself as source for GitHub Pages)
git checkout master
git submodule add -b gh-pages -- /remote/url/of/your/own/repo gh-pages
git commit -m "Add gh-pages branch as submodule"
git push
You will have a gh-pages subfolder, that you can update at any time with:
git submodule update --remote
Related
I am trying to see a static html file. My github url is anuragasaurus.github.io and my repo name is js-playground, it contains a index.html file.
I am trying to open anuragasaurus.github.io/js-playground/index.html but it's showing 404.
Can anybody tell me how can I access index.html file in my js-playground repo.
In order to view your project files as static webpage, you should store your files not in default master branch but in gh-pages branch.
You can create this branch using multiple methods but in order to find out the convenient one, you can use this GitHub Pages link.
Basically, let's assume that you already have master branch. If you are using git command line tool, you can do that with these steps:
cd your-project-folder
git checkout -b gh-pages (it will create new branch and switch to it)
git push origin gh-pages (it will create new branch on GitHub repo and push the existing files to it)
I created repo [username].github.io, pushed first commit in gh-pages branch, have been waiting for 30 mins (GitHub says, it shouldn't take more than 10) and got 404 page trying to load my page.
Checked out with different browsers, results are the same.
Here's the way how I've done it:
$ git clone http://github.com/RedCorbie/RedCorbie.github.io
$ git add index.html
$ git commit -m "Initial commit"
$ git branch gh-pages
$ git push origin gh-pages
What's the problem?
The documentation mentions:
If you generated a User Pages site, the code lives in the master branch instead of the gh-pages branch.
In your case, you might want to create and push a master branch.
git checkout -b master
git push -u origin master
Update August 2016: Simpler GitHub Pages publishing now allows to keep your page files in a subfolder of the same branch (no more gh-pages needed):
That means project pages can now also live on master.
In an attempt to make my workflow a bit neater, I came across the source tag, which allows me to host my "dev work" in a separate folder than my _site.
This is awesome, but it does not appear to be honoured by Github pages? I feel like I am doing something wrong though, so just wanted to check. I couldn't find much about it online.
In this case, I don't explicitly need github to do it, but it would be great to have this consistent workflow for projects that do rely on github pages.
Thanks!
GH Pages overrides the source setting in the Jekyll config file:
https://help.github.com/articles/troubleshooting-github-pages-build-failures#source-setting
http://jekyllrb.com/docs/github-pages/#project-pages
You don't need to change source or destination parameters to version them separately. You can just version them in two different branches from the same repository.
Why versioning in different branches ?
If you need some plugins (generator, tag, ...) or build tasks (gulp, grunt, ...) that will not run on gh-pages, you will have to publish your Jekyll sources in a branch and your build results in a separate branch.
For a User / Organization site, it will be master for the site build, and sources (or any name you like) for the code. A User / Organization site will be versioned at github.com/userName/userName.github.io and hosted at http://userName.github.io (or with a custom domain)
For a Project site, it will be gh-pages for the site build, and master (or any name you like) for the code.
A Project site will be versioned at github.com/userName/projectName and hosted at http://userName.github.io/projectName.
Steps for User\Organization site
create a repository on github (eg: https://github.com/userName/userName.github.io)
go to command line and cd pathTo/yourJekyllSource
git init
git remote add origin git#github.com:userName/userName.github.io.git
jekyll new . creates your code base
in _config.yml, set the baseurl parameter to baseurl: ''
in .gitignore add _site, it will be versioned in the gh-pages branch
jekyll build will create the _site destination folder and build site into it.
git checkout -b sources
git add -A && git commit -m "jekyll base sources" commit your source code
git push origin sources push your sources in the sources branch
cd _site
touch .nojekyll, this file tells gh-pages that there is no need to process files
git init
git remote add origin git#github.com:userName/userName.github.io.git
git checkout master
git add -A && git commit -m "jekyll first build" commit your site code
git push origin master
And your good to go !
Your deploy can be made like this :
cd pathTo/yourJekyllSource
jekyll build
git add -A
git commit -m "your commit message"
cd _site
git add -A
git commit -m "your commit message"
Steps for a Project site are described here and I've made an automation Rakefile, it can do everything for you from setup to deploy.
Enjoy !
Is there a way to fork from a specific branch on GitHub? … For example, moodle has many branches (1.9, 2.0 … and so on). Can a clone be performed of just branch 1.9 and not the master branch always? Is it possible to clone a specific branch onto my PC?
I don’t know a native way yet, but you can do it following this recipe:
Fork the repository in question (called ‘upstream’) on the GitHub website to your workspace there.
Run the GitHub desktop application and clone the repository onto your PC.
Use the GitHub desktop application to open a shell in the repository. (The git commands are not available from the default PowerShell unless you configure that manually.)
Set the source repository as upstream:
git remote add upstream https://github.com/{user}/{source-repo}.git
Fetch the full upstream repository. (Right now, you only have a copy of its master branch.)
git fetch upstream
Make your file system copy the branch you want and give it any name:
git checkout upstream/{branch-in-question}
git checkout -b temporary
Publish your repo using the GitHub desktop application.
On the GitHub website, open your repository and click ‘settings’.
Change the “Default branch” to ‘temporary’. (Just change the drop-down menu, you don’t need to click the “Rename” button.)
Go back to your repository, go to the ‘branches’ tab, now you can delete the “master” branch.
Delete the master branch on your shell and make a new master branch:
git branch -d master
git branch master
git checkout master
git -d temporary
Once more, publish your repo using the GitHub desktop application.
On the GitHub website, open your repository and click ‘settings’.
Change the “Default branch” back to the (new) ‘master’ branch.
Go back to your repository, go to the ‘branches’ tab, now you can delete the “temporary” branch.
This should be what you were looking for. Perhaps GitHub will provide a more convenient way to do this in future (e.g., clicking “Fork” from a project’s branch results in exactly this behaviour).
Cloning means that you create a copy of the whole repository in your account including all branches and tags. However you are free to switch and track branches however you like.
No command line needed. Just create a new branch in your forked repository in GitHub. GitHub will ask you if you want to clone/mirror this new branch from the upstream repository. You can give any name to the new branch.
Yes, you can clone the single branch. For example, you have a branch named release1.0. If you would like to clone this branch into your pc then use the following line of code:
$ git clone git#bitbucket.org:git_username/git_repository_example -b release1.0 --single-branch
For those who don't like working with command-line. Here is a simple guide using the desktop client for GitHub:
Click the fork button of the repo on GitHub.com:
Make sure you have the desktop client installed
Click this button:
Clone the repo
In the desktop client, select the desired branch
Select the branch you'd like to work on and you're done
I'm posting here the method I've used.
Like the OP I wanted to only copy/fork one branch. But couldn't find an easy way.
in your repo create a new branch. It doesn't need to have the same name as the branch you want to fork
once created, verify that it is the selected branch, and click "Compare"
reverse the order of comparison (I have a userscript for that, see my profile if it's something you want to test).
the "base" repository must be yours, with the branch you've created
the "head" repository is the original, and the branch is the branch you want to fork
hit "create pull request" and continue until the PR is applied
That's it. You have the branch forked.
I'm using bitbucket but I'm sure this would work for GitHub as well.
Create a new repository
Checkout the branch using GitExtensions
Click Push to open the Push dialog
Set the destination URL to the new repository
Set the destination branch to "master"
Push
Your new repository will have the full history of the one branch only (not all branches like forking will have).
A fast, alternative approach is to create your own new repo.
Go to https://github.com/new and make a new repo. Do not initialize with README.
Scroll down to get your git remote
Then:
git remote rm origin
git config master.remote origin
git config master.merge refs/heads/master
// Run code from above image
git push --set-upstream origin yourbranchname
You will have a new repo with the original repo's code and a branch that can be made into a pull request.
SOLUTION:
For remote repository on GitHub and local repository
After fork all branches to your GitHub repository, you can delete Redundant branches in your GitHub repository.
And then you can only clone the branches you need to local.
Step One
Step Two
Only For local repository
git clone -b <branch name> --single-branch <repository>
If you want to further save your disk space, you can clone remote repository without history:
git clone -b <branch name> --depth 1 <repository>
notice: --depth implies --single-branch unless --no-single-branch is given.
https://git-scm.com/docs/git-clone
Switch to the branch you need in source repo
Click "Fork". You'll get forked master and the branch you're in.
I don't know how it works with more branches, but for my needs worked pretty well.
I'm fairly new to github and web development in general. So say I have all of my project files on my Master branch and I want to push only the files needed to make my page run on gh-pages. How would I tell it to only push certain files to the new gh-pages branch? For example, when you use gulp or grunt it makes a folder that is your rendered site for previewing your site. How would I push only the contents from that site folder to gh-pages without adding all of the other unecessary that are on the Master branch?
I've been using Jekyll recently because you can still push all of the files onto gh-pages and it still works. But I have 2 repositories for a lot of my projects. One repository has all of the source files and then the other repository has only the files I need to push a working site onto gh-pages. I want to clean up my github page so it is more organized.
Thank you.
I know this is an old question, but for the benefit of newcomers to Git branches / gh-pages that might stumble across this problem, I found the least complicated way of moving files or folders from a master branch to a gh-pages branch is to do the following.
# First switch to the gh-pages branch
git checkout gh-pages
# Next checkout the specific file you wish to add to the gh-pages branch
git checkout master -- <path/to/file/folders/on/master/branch>
# Perfom the commit
git commit -m "Updated index.html from master"
# And push
git push
Assuming the file(s) you are trying to add to the gh-pages branch exist on the master branch you shouldn't have any problems following the above steps.
If you are using nodejs and npm you can use the gh-pages package from the command line to publish to a gh-pages branch from a specific directory. The gh-pages package has a command line utility.
Installing the package creates a gh-pages command line utility. Run gh-pages --help to see a list of supported options.
Note: You mentioned using Gulp and there is an npm package called gulp-gh-pages that I use successfully to create gulp tasks to put into my deploy workflow.
I believe you're looking for git subtree merge.
The idea of the subtree merge is that you have two projects, and one of the projects maps to a subdirectory of the other one and vice versa.
When you specify a subtree merge, Git is smart enough to figure out that one is a subtree of the other and merge appropriately — it’s pretty amazing.