سؤال

I have a static website using Jekyll hosted on GitHub. The problem is, I don't really need the master branch, as the only thing the repository contains is the website.

This way I have to git checkout gh-pages, then git merge master, and then do git push origin gh-pages.

Is there any simple way, where I could get rid of the gh-pages branch and push directly from master?

هل كانت مفيدة؟

المحلول

The problem is, I don't really need the master branch, as the only thing the repository contains is the website.

Is there any simple way, where I could get rid of the gh-pages branch and push directly from master?

In your own words, you don't need master. Delete it. Work in gh-pages.

نصائح أخرى

I use Jekyll myself and I always makes change on master branch and push it to origin...

Nobody forces you to create branches... If the level of changes you are making does not need multiple branches then just make your changes on master branch and do git push origin.

The way you are stating your problem somewhat sounds like master branch is a special git branch which is not true. At the end of the day master or gh-pages differ only in the commit they point to and the refspec rules associated to them but they fundamental carry the same semantic.

Delete you gh-pages branch doing: git branch -d gh-pages. If gh-pages is not merged yet then merge onto master before deleting gh-pages. Then just go on and use only master branch.

Suppose you did want to keep both branches (so that you also have documentation).

You could just run a script after pushing to master that does:

git checkout gh-pages
wget https://github.com/{yourgitlogin}/{your-project}-master/archive/master.zip
git rm {your-project}-master
unzip master.zip && rm master.zip
git add -u
git add .
git commit -m "update master"
git push
git checkout master

Something like this would add your entire site as a subdirectory under gh-pages, enabling you to have both documentation, and an up-to-date running example of your site in the same location and with little effort.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top