Github Desktop says my own local branch is "a protected branch" and I can not commit to it. How do I remove this protection? - github

I forked a Project on GitHub and then opened my fork in GitHub Desktop (Windows 7). Locally, I created a branch and made changes to the code. Now I want to commit the changes, then publish the branch to my fork on GitHub, and then make a pull request to the original repo. That is how it used to work the last time I did this.
But now GitHub Desktop unasked protects this branch ("branch is a protected branch. Want to switch branches?"), and I can not commit things to it. On GitHub, in the settings of my fork, under "Manage Access", it says:
0 collaborators have access to this repository. Only you can
contribute to this repository.
But I can not do this (contribute to this repository).
How can I "unprotect" that branch and commit to it?

The solution was to first push the fresh branch without the commits to my fork at GitHub. After that the protection in GitHub Desktop disappeared, and I was able to locally commit changes to that branch and push them online.
I had to log off and log in once from within GitHub Desktop, to be able to push the branch, for security considerations, I had not logged in via Desktop for a while.

Related

"Disconnect" forked Git repos in VSTS

In VSTS, I forked a repository to develop a separate product from the original repo.
When I make a PR from a branch into master in my forked repo, VSTS defaults to merging into the original repo. I have to be sure not to mistakenly merge into the original repo with every PR.
VSTS seems to think that I may want to merge changes from my forked repo into the original one. I have no plans to do so. How do tell VSTS to 'disconnect' my forked repo from the original?
No, there isn’t such feature in VSTS, there is the user voice that you can vote: Allow option of converting forks to repos
Work-around
As a work-around (in Visual Studio) until it's fixed:
Pull the repo.
Delete the remote repo.
Create a new remote repo with the same name.
Push the repo.
You might have to create a temporary remote repo (named temp if you'd like) in order to be able to delete the remote repo. You can delete the temporary remote repo, named "temp", after you've pushed to the new remote repo.
You'll most-likely break anything (pull requests, work items) linked to the repo and also have to re-apply any policies and security stuff.
repo = the faulty fork in VSTS.
temporary remote repo = a temporary tepo created if you cant delete the fork repo.
new remote repo = the new repo to be used instead of the fork.
It seems like one should disconnect the old remote origin and set the upstream before pushing. Maybe the push with the --set-upstream overwrites that?
Here's what I'm did:
git clone ACCOUNT#vs-ssh.visualstudio.com:v3/ACCOUNT/PROJECT/FORK-NAME NEW-NAME
git remote rm origin
Create the new repository on VSTS for NEW-NAME
git push --set-upstream ACCOUNT#vs-ssh.visualstudio.com:v3/ACCOUNT/PROJECT/NEW-NAME develop
This worked for me to change from a fork to a repo. I can see the full history and open changesets from the web viewer. I did this in Azure DevOps (formerly Visual Studio Team Services AKA VSTS). I did not test against GitHub.
Pull requests and pushes are lost. Commits are still linked
I'm not sure if you need to do the push multiple times for different branches. My fork only has a develop branch anyway. I only create a master branch so git flow doesn't complain.

Github Protected Branches with GitFlow

I've got a repository with my develop branch protected and I'm using the GitFlow branching model. There's two branches; develop (containing features currently being developed) and master (latest deployed production code).
My develop branch prevents commits being directly made via GitHub's Protected branches. When you locally finish a hotfix using GitFlow, it automatically merges the hotfix branch into your local master and develop branches. However, pushing changes directly on the develop branch are not permitted as this is a protected branch
How can you overcome this? At the minute everytime I am creating a hotfix I have to:
Manually turn off the branch protection
Push the develop branch
Turn it back on
This is not automated and therefore, not really acceptable.
Are you the owner of the GitHub project and do you have the administrator role setup with your account (or can you grant administrator access to your account)?
In this case I would recommend you not to protect the branch for administrators. This way you can guarantee that other persons are not pushing directly to develop, but all "knowledged devs" with administrator access are able to. They should be aware of what they are doing, though.
You can edit this behaviour under https://github.com/${name}/${repo}/settings/branches/. My settings do look like this (the last checkbox is important):
Note: maybe you could also use the "Restrict who can push to this branch" option.
Enable 'Require pull-requests' on GitHub.
After you merge the hotfix in your local master you can create a hotfix branch from it, to create a pull-request in origin. Your master will be different, but you can reset and stash and pull in the origin/master.
git checkout -b hotfix
git push origin hotfix
# merge
git checkout master
git reset origin/master
git stash
git pull --rebase

Update all branches on forked repo with github.com?

I have a forked repo. The original repo has been updated and I need to pull in these changes. I would prefere to use github.com for this rather than the command line if possible.
From the github.com page of my fork I have a button called Compare which allows me to compare my branches with the branches in the original repo, and merge if there are changes. This should do what I want except that the changes I need to update are in a new branch that isn't in my repo.
IMHO, the best way to do this is by installing the Pull app in GitHub.
After forking a repository, you can then enable the app for the
repository, and then configure the app for the forked repository. 🙂

Github to launchpad sync

I am working on a open source project which uses bazaar for versioning and launchpad for repo. The project also has github repo but launchpad repo is primary. I am behind college proxy so i can't access ssh required to connect to launchpad to merge/push changes. Is there a way, that i commit, push all changes on my github account, and they get reflected on my launchpad account too. Can I send merge requests too?
This will give you overall idea , how to do that
create your project test in github and will be owned by organization name Acc.
then just push the master branch to test
Now fork the project and clone
Push all your local branches to your GitHub fork git push -a origin
And checkout that branch using git checkout <branch_name>. And then push to origin of that branch.
Launchpad is a project-centric environment, so you will most likely have a GitHub organization that owns the ‘main’ repository and encourage all members and newcomers to fork from that.
within fork developer can able to work on that, usually when about to issue a pull request – GitHub’s version of a merge proposal, pull down changes from the upstream organization master into their master. Since this will happen relatively often it is easiest to add an additional ‘remote’ target for it:
git remote add acc `http://github.com/acc/test.git`

New to github. Fork or branch?

I'm new to github. I just downloaded the Windows GUI github version. I want to contribute to someone's project. Should I fork the original repo to my repo and start from there or should I branch off from the original repo? How do I merge it back to the original repo later? How to do this on the GUI or do I need to use Git shell?
Unless the original author lets you push to his repo, you won't be allowed to do it. The usual process to contribute to a project you don't own is to:
create a fork of the repo
clone the fork you've just created to work on it locally
create a branch to add your contribution
add commits to this branch
push it to your forked repo on github
send a pull request to the original repo on github so that the author can fetch the branch from your repo, test it, and integrate it if he likes it.
This is explained when you click on the giant 3 - Fork a repository link on Github's home page