Making a certain branch (not master) be the first branch on my github repository - github

When people click on Cataclysm-DDA on my profile (https://github.com/DanielPBak?tab=repositories), they are directed to my master branch, but I'd rather they be directed to a different branch (washboard_batch) where I've actually done some work.
I'd like to do this without changing the default branch. The only thing I want to change is the branch that a visitor is initially directed towards.
How can I do this?

Your default branch is named master. If you have admin rights over a
repository on GitHub, you can change the default branch on the
repository.
https://help.github.com/articles/setting-the-default-branch/

Related

GitHub not showing activity?

My GitHub account shows that my latest contribution was on March 21st.
When you head to commits section, you can see that I did commit today and yesterday.
Why isn't it shown in my activity?
Also - for quite a long time I have been commiting to projects from my work-account not realising that it makes me last contributor in my own project :D. Is there a way to link this email (work) with my account?
Check first the "Why are my contributions not showing up on my profile?":
Commits are only counted if they are made in the default branch or the gh-pages branch (for repositories with project sites).
If your commits are in a non-default or non-gh-pages branch and you'd like them to count toward your contributions, you will need to do one of the following:
Open a pull request to have your changes merged into the default branch or the gh-pages branch.
Change the default branch of the repository.
And you were committing on the non-default branch New-Backend-Integration.
Also, the username/email used is important: you can add emails to your GitHub account.

Hide master branch in GitHub Desktop

Our implementation of GitHub is very basic.
We have one master branch (default) and then one open branch (DEV) for new developments.
Ideally we won't have more than one branch open at the same time.
Master branch is a protected branch so only admin can do changes on there.
The idea is to use GitHub Desktop to manage the developments locally in a computer as it would be too complex to manage it via the WebUI due to the kind of files being used.
Also we have the challenge that team is mostly consultant/external and rotating, so not everyone is familiar with the GitHub funcitonality...
Due to this, I would like to know if it is possible to avoid checking out the master branch when cloning our repository.
I am mainly aiming for this approach as I have problems when someone clones the repository locally and starts developing into the local master branch (without switching to the DEV branch first) and getting the error when pushing to server (due to the protected branch).
At that point the developer has already developed a lot and now is time for him to switch all his development to the proper branch instead of using the master one...
Is there any way to achieve that initial checkout from master to be avoided?
EDIT:
just immediately after posting I thought on changing the default branch to DEV so when someone clones it will always be directly targeted to the DEV branch instead of master...
Would this have any bad consequence for such a simple implementation?
Note that branch is created by admin as well as deleting it after pull request has been merged...
So this could be his responsibility to change the default branch every time a new development needs to be done and move it back to the master when development is finished...
Does it have sense?
When you clone a repository, whatever is "checked out" on the remote end becomes the default branch that is checked out on the local end.
For remote bare repositories, which is usually the norm, you have a "default branch" configuration that is used. In your case this is set to master.
You can change this on github to be DEV instead, so that fresh clones of the repository checks out DEV by default instead of master.
You do this by navigating to your repository on github, and click on the "X branches" button that is just to the right of the button/dropdown that shows the default branch selection on your repository page:
on the page that shows branches, click on the "Change default branch" button to the right of your current default branch:
and then finally select your new default branch and click Update:

github site from gh-pages branch

I have GitHub site like example.github.io and want to load this site from the gh-pages branch!
how can I do?
now I can't change branch because my repository name is example.github.io
When you create yourusername.github.io you have to commit directly to master. It's meant as a website (unlike a repo that has a website that hosts to yourusername.github.io/reponame/*.
Since you already have a branch with the website, just merge it into the master branch. This can be done from the command line, the Github website or Github Desktop.
The logic
Example: You have a repo (username.github.io). You also have two repos set up with Github pages: repo-1 and repo-2.
username.github.io is the root. You're free to do pretty much anything you want with it. Creating directories will be relative to the root of the domain. When you connect to the domain, it finds the files from the master branch. If you go into the repo settings for username.github.io, you'll see this:
You're locked to the master branch. You can still use other branches for adding features, but what the actual website consists of is what's on the master branch.
The difference between the username.github.io repo and repo-1 or repo-2 is that username.github.io allows editing access to the directory root (e.g. http(s)://username.github.io/index.html) where as repo-1 and its connected pages would be at http(s)://username.github.io/reponame/index. Since the website is most likely wanted to stay out of the source itself, you can use an alternate branch to host it.
If you go into settings for repo-1 or repo-2, you'll see this:
Here you can pick. If you have multiple branches, you can select a different one to host the pages. You can also select the option to use the /docs folder for the website.
TL:DR; When using username.github.io, the master branch is the one that actually hosts the website. Think of it as the production branch. The others can't be accessed from the website
From the OP's comment:
So I can't use the gh-pages branch for Github site! yes?
Update Sept. 2020: yes, you now can.
You can use any branch you want.
"Build and deploy GitHub Pages from any branch"
Repositories that use GitHub Pages can now build and deploy from any branch.
Publishing to the special gh-pages branch will still work the same as it always has, but you can now choose a different branch in your repository as the publishing source.
This functionality also removes the hardcoded dependency on user and organization pages having a master branch.

How do I rename branch on the GitHub website?

I don't know how to run command line stuff. I just don’t have the environment.
So I'm trying to rename a branch on the GitHub website. It was, by default, named patch-1.
Is it possible to rename it on the site?
I just did it without downloading any code to my laptop and using only the GitHub site.
The solution looks the same as #swcool’s, but I want to add about the default branch.
In my case, the name of the renaming branch did not exist.
Change the default branch (to the old branch you want to rename)
Create a new branch (with a new name)
This action will copy all the contents of the default branch (the branch with the old name) to the new branch (with a new name). At this time, you have two branches with the same code.
Change the default branch (to the new one with a new name)
Delete the old branch
I think you can, just create a new branch with the new name, and delete the old one on github.
More detail you can see here.
It is not possible to rename a branch from the Github website. You will need to do the following -
Setup your Git Environment
Follow this - https://help.github.com/articles/set-up-git
Rename branch locally & on Github
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
If you don't want to install Git, clone the repo, rename the branch locally and push it back to GitHub, you can use the GitHub API for references:
create a new branch where the old one is:
POST /repos/:owner/:repo/git/refs
{
"ref": "refs/heads/newBranchName",
"sha": "<SHA1 of old branch>"
}
delete the old branch:
DELETE /repos/:owner/:repo/git/refs/heads/oldBranchName
That way, you will have "renamed" (create+delete) the branch without having git locally.
And, as commented by user3533716 below, use the GitHub API for listing branches to get those branch SHA1:
GET /repos/:owner/:repo/branches
Since Jan., 19th 2021, you now can rename a branch directly on github.com:
Support for renaming an existing branch:
You can now rename any branch, including the default branch, from the web.
If you've been waiting to rename your default branch from master to main, we now recommend doing so using this feature.
When a branch is renamed:
Open pull requests and draft releases targeting the renamed branch will be retargeted automatically
Branch protection rules that explicitly reference the renamed branch will be updated
Note: admin permissions are required to rename the default branch, but write permissions are sufficient to rename other branches.
To help make the change as seamless as possible for users:
We'll show a notice to contributors, maintainers, and admins on the repository homepage with instructions for updating their local repository
Web requests to the old branch will be redirected
A "moved permanently" HTTP response will be returned to REST API calls
An informational message will be displayed to Git command line users that push to the old branch
This change is one of many changes GitHub is making to support projects and maintainers that want to rename their default branch.
Branch names will not change unless the maintainer explicitly makes the change, however this new rename functionality should dramatically reduce the disruption to projects who do want to change branch names.
To learn more about the change we've made, see github/renaming.
To learn more, see Renaming a branch.
To rename a branch on the Github website, just go to your repo's home page, click on where it says "branches"
Then, find the branch you're interested in, click the pencil button
and from there, you can rename your branch.
If you want a GUI based solution - download the Git Client "GitKraken". It supports doing this from UI by right-clicking on the branch name and choosing "rename [branch name]".

CLEARCASE: How do you keep tracking the upstream version

My current employer uses clearcase (I believe Base-CC) for version control. Our project has a branch, and each user has his own branch on top of it. The configspec of the users shows elements from the user branch, then from the project branch, and then from the company-wide branch.
The current modus-operandi, is that the users merge in their changes back to the project branch, and keep working on their own branch.
The problem is, that after the user merges his changes, he still has a branch for this element. Then, when the someone else modifies the project, he still sees his outdated version.
I want the following:
if a user has a checkedout file, display it.
if a user has unmerged worked, display it.
if a user has merged work, show the lastest version from the project
I thought of marking the element branch as obsolete after each merge, but the users still sees it, and not the latest from the project.
Then I thought of changing the config spec, to somehow ignore merged-in branches, but I do not know how to do that.
Any ideas?
You can reuse your personal dev branch, but the correct workflow, when a dev merges his/her branch to the upstream branch (here the project one) is:
first merge the project branch to the personal dev branch
resolve any conflict locally
then merge personal dev to project.
That way:
you don't have to modify the config spec after each merge,
you make sure the merge will be a trivial one,
and the personal dev branch can represent easily the LATEST from the upstream branch after merging (again) the project branch to the personal dev branch: the delta will be minimal.