Viewing a separate branch of GitHub Page - github

I have recently started using a GitHub repository to work on a personal web project, since GitHub allows me to host a website via GitHub Pages.
Is there a way to view a separate branch of this web project in my browser, just like I can view the master branch by accessing the URL [username].github.io? Otherwise, I find it difficult to really make use of the GitHub workflow since I'd have to commit changes to the website directly to the master in order to view them in the browser rather than reviewing changes in a separate branch.

Not that I can see. You can only view pages from:
gh-pages branch
or since August 2016, from master, or master:/docs
But each time, GitHub pages will reflect the content of one source, not giving an easy way to switch between branches.
A workaround would be to have a separate account, for a separate [username-review].github.io domain, allowing you to publish first in that second site, before pushing to the first one.

Related

List associated issues in Pull Request

In our Github organization, we merge everything to develop. Once a week we merge everything from develop to master. We want to have a list of all issues in the PR description based on the commits, which are linked to the issues (with #number of issue).
We have a Github Actions workflow that automatically creates the master PR. This PR usually has a lot of commits. We try to find a way to automatically write a comment with the titles of the issues which are referenced in the commits!
I tried to use the Github REST API but Im way to unexperienced with that so nothing seemed to work. I also tried to use some github changelog tools like this and this and tried to add them to a github action worklow, no success. Im also pretty new to github actions and coding in general.

Show commits and description but hide code in repository [Github]

I've almost done my first big project in React+Typescript+Redux and started it on Firebase with users and some database conneted with logged users.
It was supposed to be my project to portfolio before looking for my first dev job, but it start to be very complex.
Now I have idea to use it in the future to make commercial app.
So the problem is I don't want to publish my code on github, but at the same time I want to publish all my commits and repository description on Github for recrutiers (and all my tasks from trello table). Is it possible to publish only commits and description from github repository?
No, this is not possible. If your repository is public, anyone can clone the entire repository. The only way to make your code inaccessible is to make the repository private, which means nobody can see it without having permssion.

Github pages only works on first repository, won't work on new project

I create a repository and renamed it to username.github.io, which worked. I decided I do not want to use that repository for my github pages, so I renamed it to something else, created a second repository, then set that new repository to have the github pages name. When I try going to the url, it doesn't work. But when I set put the name back on my first repository, it works again, indicating that my github pages is locked to the first repository that I used it on.
How can I fix this?
This thread suggests that, from GitHub support:
We keep redirects for moved and renamed repos indefinitely, but new repos take priority over redirects.
That means if a new repo is created at an old location, the redirects will break in favor of displaying the new repo, for as long as that new repo exists.
If it does not work in you case (after, say, 24 hours), you should contact the GitHub support to ask why the new https://github.com/username/username.github.io is not taken into account when accessing https://username.github.io.

How can I make a second fork of a GitHub project?

I want to fork a github project to fix a couple of issues and then send a pull request.
The problem I'm running into is that I've already forked the project to adapt it for another user base.
Is it possible to create a second fork? If so, how?
When I try to fork now it just takes me to the previously created fork.
There is no way to have two forks of the same GitHub project unless you use two different GitHub accounts.
So:
Create a separate GitHub account (and verify the email)
Fork the
project
Invite your main GitHub account as a "Collaborator" (from
the settings)
You may need to add the extra step of creating an organization with the new GitHub account and inviting your main github account as an owner of the organization (also make sure your new fork is in that new organization). This will let you do things like deploy automatically to a Heroku app that is connected to your main GitHub account.
Why can't we just have multiple forks???
I mean that I could just commit and push without making a pull request, but I want to do it the offical way and I want somebody else to review the changes before I push to a public project.
GitHub pull requests do not need to be submitted from a fork; they work within a single repository as well:
Pull requests are especially useful in the fork & pull model because they provide a way to notify project maintainers about changes in your fork. However, they're also useful in the shared repository model where they're used to initiate code review and general discussion about a set of changes before being merged into a mainline branch.
There's nothing stopping you from creating a pull request even if you don't technically have to. This is often considered a best practice, and GitHub's own Flow model is largely based on pull requests.
Creating a pull request within a single repository is very similar to creating one from a fork:
Create a feature branch and push your work to that branch on GitHub
In the GitHub web UI, switch to your feature branch
Click the "Compare" & review button
The trick is not to use the master branch to create pull requests. Then you won't need to create multiple forks since you can make as many branches as you need and make pull requests against each branch independently.
Given a clean forked repo, create a dedicated branch and use that branch for the pull request.
You can create branches from the web UI (although it is not obvious).
Click the branch selection dropdown, type the new branch name in the input field, and then you'll see a clickable link Create branch: <new-branch-name> as shown below. The tricky UI part is that it might not be very obvious you should click the "create branch: xyz..." — it is NOT displayed as a button or as a hyperlink, and there is NO indication that this is a clickable link. Moreover, there is NO hint whatsoever that a branch can be created until you type in the search box — anyone would probably assume that the search box is used exclusively for searching branches, and not for creating them.
In case you already made changes directly in your fork's master branch then consider moving those changes into a dedicated branch and hard resetting the master branch to the original remote so that you keep it clean for synching with the upstream repo.
See also:
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository
The best way, recommended by github manual, is use command line git, mirror clone your repo and push it to your github.
https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/duplicating-a-repository
If you strongly prefer GitHub web interface to the command line, a GUI friendly workaround is create a new organization and fork to that new organization.
Another GUI way I can think of is to declare a fork as a template repo using repo's setting so you can create as many forks as you need.

Send a GitHub pull request with a single file change

I forked a repo on GitHub, made and pushed changes to my version, and now want to send a pull request to the original repo.
How can I send a pull request with changes affecting a single file and not include the commits and changes done on the other files?
You now (January 2015) can do it directly from the GitHub web interface.
See "Quick Pull Requests":
When using your browser to edit a file on GitHub.com, the web-based commit composer lets you quickly propose a change to a new branch and then immediately open a pull request for discussion and review:
Reducing the time it takes to open a pull request lowers the contribution barrier, and having this workflow available entirely within the browser makes collaboration more approachable for people with all technical skill levels.
Create a new branch from origin/master, commit the right changes to it (you can use git cherry-pick to copy commits among branches) and create a pull request of that branch.