I have the following website hosted on GitHub Pages. This is the GitHub repository. I have two branches: main and gh-pages. Whenever I push a commit on main I need to keep gh-pages in sync using the following commands:
git checkout gh-pages
git rebase main
git push origin gh-pages
git checkout main
Now I would like to avoid this waste of time with every commit. I searched different websites for a solution and I found, for example, this:
It suggests only keeping the gh-pages branch and removing the main one. At the end of the article, there is this text:
Update:
This approach is no longer necessary, now that Github lets you use
master, or a /docs folder for github-pages.
Does anyone know how I can use the main directly in GitHub Pages?
Related
I have only ever used git add . for this project, but somewhere along the line I started getting the strange "modified content, untracked content" error on one of my subdirectories (called users). Other stackoverflow answers didn't work for me. I used checkout to go back through previous commits, but the buggy/untracked subdirectory didn't change with the rest of the directory. I ended up making manual changes to it and then running git checkout master to make sure everything else was back where it started.
Git is saying that I'm bisecting, and it won't let me commit. I looked over stackoverflow answers, and tried some of the following commands:
git pull:
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
git pull origin master:
fatal: 'origin' does not appear to be a git repository
git branch --set-upstream-to=origin/master master:
error: the requested upstream branch 'origin/master' does not exist
hint:
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint:
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.
git pull --rebase:
There is no tracking information for the current branch.
Please specify which branch you want to rebase against.
Apologies if these commands are all over the place. I intend to really learn how git works soon, but right now I just want to commit the changes so I can deploy my project.
UPDATE: I used git bisect reset, created a new branch out of my detached head, and then merged with the master. This kept the changes I made, so now I just need to figure out how to get users tracked again in my commits. git add users still isn't doing anything.
I've been trying to create a personal site using blogdown and the academic template:
blogdown::new_site(theme = "gcushen/hugo-academic")
However when I try to attach the site to github pages I get the error:
our site is having problems building: The variable {{2\left( {x + 4} on line 58 in content/slides/example-slides.md was not properly closed with }}. For more information, see https://help.github.com/articles/page-build-failed-tag-not-properly-terminated/.
It looked properly terminated...but regardless, I've tried to delete the file but alas the same error comes up even with its removal.
The site is https://github.com/sebastiz/SebastianZekiCV/
In order to publish a user site via github pages either:
1) the name of the repository must be exactly .github.io
In this case, the pages will be served from the HEAD of your master branch (or the gh-pages branch - your choice). The root of the repository is the root of the site.
2) the name of the repository can be anything. In this case, it will served from the master branch, but from the /docs directory.
In either case, github pages will run Jekyll. The only way to stop it is to have only "static" files - e.g. CSS, html pages, images, etc.
What you can do is create two repositories - one will be your source; the other will be the actual pages served. You can use hugo -d <path> to tell hugo to build its output in the root of the clone for the "output" repository.
Further reading:
github pages help configuring source
hugo command reference
For this problem, the ideal solution which is suggested is to create separate repositories for code and static content. However, the error can be solved by disabling Jekyll to run.
Create a file called .nojekyll at the root of your repository.
You can then go ahead and choose publishDir = "docs" and server from the docs/ directory in the master branch.
I was publishing user pages with GitHub pages. After renaming my repository from username.github.io to username.github.io__, and renaming back my repo to username.github.io my pages are not showing up anymore.
The purpose of renaming my repo was to unpublish my pages for a short period of time.
Can someone give me a solution to republish my pages?
It was just needed to update with empty commit :
git commit -m 'rebuild pages' --allow-empty
git push
While an extra commit solves the problem, you should note a few things.
First, to fix the issue, push a new commit.
git commit --allow-empty -m "Empty commit"
git push
Second, make sure that the branch you committed is the master branch. For example, in my case, I make changes to the develop branch, and then I had to merge develop to master so that the actual page gets built again.
I need some help because I have some codes that I pulled from my repository branch and changed a couple of things in it.
What I need is to push it into another repository that I have been a collaborator in.
Been trying to push the codes, and trying to access it but to no avail.
Can anybody help me with this one? Any help will be greatly appreciated.
You have two different repositories where you manage to code. First one from where you clone/pull code and made some changes. Second one is what, where you want to push your latest code.
If you clone your repository from GIT then It automatically attach its GIT Url into your application. To check run this command
git remote -v
Result:
origin https://username#github.com/project-name.git (fetch)
origin https://username#github.com/project-name.git (push)
This is url from where you clone/pull your latest code. Now we have created alias of URL as ORIGIN.
so when ever you want to push your code, you will do
git push origin master
Now Add another GIT URL(remote) where you want to push your latest code.
git remote add origin_two https://username-two#github.com/project-name.git
So now commit your changes and made a pull request from your secondary GIT URL this way.
git pull origin_two master
If you got any conflicts then make corrections in code and then again add untracked files using
git add file-name
add a commit message
git commit -m "Your message"
and push your code to git
git push origin_two master
If you are working with branches:
You have two repositories now for a single application. So for that each repo has their own branches, to list down branches for each origin just follow
git branch -a
will list all the branches from two remotes. now If you really want to push on any other branch then you should commit all the changes on current branch an then move to your favorable branch using command
git branch branch-name
and do code here whatever code you will change now push to particular branch
git push origin_two branch-name
That's it :) Hope this can help you.
I am pushing one set of commits to GitHub from my Django app directory and another set of commits from my templates directory. Because each is a different directory, I had to set up a git remote in each one so that it knows to push to GitHub.
Here's the problem: Each set of commits has its own "master" branch that isn't aware of the other. First, I push the commits from the Django app directory's master branch to GitHub's master branch and that works fine. But then, if I push the set of commits from the template directory's master branch to the same GitHub master branch, I get an error saying that I need to do a merge before I can push. The push goes through after I do the merge, but it's annoying to have to keep merging the GitHub master to the different master branches of my different Django directories.
My question is: is it possible to set one master branch for all the different django directories I need to work with so that i can just do one push for files in all my directories? It seems that I need to initialize a .git file for each directory I want to work with which consequently gives each directory its own master branch.
That is very strange. I use a single master branch for django projects that are hosted remotely on github.
You need to make a clone of the local repo in the topmost directory to have a single remote master branch.
For example, my project name is: BigCoolApp
If you do: cd /user/BigCoolApp
You should find a .git folder in there. It will be among all the other folders. If done correctly, you will now have a single master branch for your Django project.