How can I 'unfork' in GitHub Desktop? - github

I have forked a public Github repo using the Mac GitHub Desktop client, so I can make some changes and submit them.
I have got my fork into a total mess (I am not used to working with forks) and want to start over, but I cannot find a way to tell the client my repo should track the original repo rather than my fork... it seems irrevocably bound to my fork.
How can I get the client app to forget I have a fork?

I'll put up what I found by trial and error, but someone might have a better way:
I basically deleted my repo (form) on Github, and automagically the GitHub client showed my local repo now linked to the original repo again. I was able to go through the process of creating a fork all over again with my changes.

Related

Confused first/only time github user - do I need local copy/ies to conduct the following (msg body details)

I am not a programmer/software/dev to need to get too many git[hub] tools installed, or use anything locally, if someone could please answer for me a very simple question.
Background: the only way I could ask for some modifications for an environment I need to work on, non-software-dev related, is via what it is being described to me as a request I need to produce as described below:
go to this GitHub URL (I have a login for that)
create a branch
modify files X, Y and Z (apparently some orchestration configs) you need, as described in other instructions
commit
push
create a PR, and someone will check, approve and trigger the orchestration tool with the configs you modified, and get you what you need
Is all of the above possible using the web interface to GitHub, via my browser, without the [almost all instructions I found, so far, online, pointing to] installation of git (desktop or CLI) on my laptop, creation of a local copy of the main/master repository, then branching locally, then ... ?!?
Yes, you can do all of those things you listed out via the browser as long as you follow the steps correctly.
If you open the file in the browser you can click edit and edit the file. After you are done editing, you can type a commit message and create a pull request on a new branch.
Here you can click on create a new branch and start a pull request. It will do those things automatically.
If you have no write access of the repository it will actually directly create a fork on your account with the changes and start a pull request...

Safe way to rename GitHub repository to the name of one I just deleted?

I had 2 repos on Github: "RepoName" and "RepoName_old". I thought I was going to rebuild my project but changed my mind and have been improving "RepoName_old" ever since. I deleted "RepoName".
If I rename "RepoName_old" to "RepoName" (the deleted repository), will something go horribly wrong? The official documentation warns against trying to pull from a branch associated with the old name...I guess that's a different thing...will GitHub Desktop acknowledge the new name after I make the change?
I have terrible experience mismanaging my git repositories and I want to avoid another setback by being informed and careful.
GitHub Desktop is a local tool which should reflect the changes done on GitHub.
On GitHub side, if you have deleted RemoName, you should be able to rename "RepoName_old" to RepoName.
Check first that it works on github.com.
Then try and clone it in command line, and, with GitHub Desktop, add it from your local folder. That should force GitHub Desktop to recognize RepoName with its new origin URL.

Can't fork a repository on GitHub

I'm trying to fork this repository, but getting an error message:
You can't fork this repository at this time.
I've read the license, and tried forking from another computer using VPN, in case of security conflict of my browser and GitHub, but it still don't work, and I can't even guess why so. Please tell me, what am I doing wrong?
This also happens if the user has blocked you
Tested today, May 2021.
A similar related message if you try to open an issue on a repository whose owner blocked you is:
You can't perform that action at this time.
You can just manually create a new repository and reupload the code there however. You just won't be able to send pull requests.
That sounds like a temporary GitHub issue.
Creating a fork isn't dependent of a license or vpn. It's just a http call in your browser.
Update: I forked the repo without issue.
If you already have a fork of the original repo, you cannot have another fork.
You can add the other repo as a remote though and use code from there.

How can I copy an git repository in Xcode to github?

Every time a try to use github I get tangled in a series of errors that seem to have no solution and I give up. This time I thought I'd try to get help.
I have a local repository created and managed with Xcode. All the local git functions in Xcode work with no problem. Now I want to put this project on github so others can see it. I logged into github and created a repository. It's this one:
lummis/CS193P-2015-Assignment-5
I added a .gitignore file but then deleted it again because I thought it was causing an error. I tried adding a readme file but wasn't able to. I got some error that didn't make sense to me so I gave up on that. So at this point the github repository is empty so far as I can tell.
My local repository has many commits and is currently up-to-date. IOW there is nothing to commit. But when I do "Source Code / Push" I get the following error:
Working copy out of date. Try pulling from the remote to get the
latest changes then push again.
So I try to do that in Xcode by doing "Source Control / Pull". But then I get this error:
"github/master" is not a valid remote branch to pull from. Please
choose a different remote branch.
But there is only one branch. There is no other branch (local or remote) to choose. So I'm stuck in a Xcode-github error loop again. I searched for information about this but didn't find anything relevant. I have the Pro Git book and read and understood it at least thru chapter 2. But that doesn't help on interacting with Xcode.
Can anybody say what I need to do? I thought of deleting the remote repository and starting over but apparently there's no way to do that either!
I know lots of people use github so it must work once you know how to use it but it's a big source of frustration for me.
You have a local repository with "many commits". Let's imagine that we have three:
A---B---C
^
master
Your remote repository on GitHub also contains commits, but they are different ones from what you have locally, e.g.
Y---Z
^
master
At least one of these remote commits was created through the GitHub web interface, which creates a new commit each time you use it.
Because the two repositories contain no common history, Git can't figure out how to handle a push from your local repository to the remote one. It will refuse to accept such a push rather than making any remote commits inaccessible, which is what you usually want.
In this case, commits Y and Z in the remote repository can be discarded. They simply add and then remove a .gitignore file, and you want the remote to reflect what you have locally. The solution is to force push.
Force pushing should generally be avoided, since it can cause commits to be discarded (like Y and Z will be in this case) or to have their hashes changed, which causes major problems with shared repositories. In this instance I don't see any danger in force pushing, which can be accomplished with the -f or --force argument to git push.
(There's nothing fundamentally wrong with force pushing, and in some situations it makes perfect sense, but it should be done with care for the reasons listed above.)

GitHub-2-GitHub issues import

As you know GitHub has introduced a Repo Transfer feature. https://github.com/blog/876-repo-transfers
This allows you to change ownership of your root repos, not forking them with your organization. However, if you have already forked a repo and want to dump all its open issues to newly created one, what should you do?
Is there any solution on GitHub-2-GitHub issues import?
Though Tekkub answer makes sense, I still implemented a short script to transfer issues:
github.com/..../gh-issues-import
You should delete the newly created one and transfer the repo instead. Transferring repo ownership takes the issues with it.
Tekkub wrote a not-so-well-received answer (-2 as of this writing): "You should delete the newly created one and transfer the repo instead. Transferring repo ownership takes the issues with it." He isn't wrong; he just didn't walk through any of the considerations and gotchas. I'll enumerate a few of those below ...
Only Works if you have "admin" access to the parent repo:
In my case, I couldn't use repo-migration because I don't "own" the parent repo so I can't authorize the transfer (parent repo in the hands of a team-member who left). So it doesn't work for me. HOWEVER ... if you do in fact have admin privileges to the parent repo you are migrating, then using the "transfer repo" function is distinctly better and nowhere near as hard as it sounds.
Git history - trivial to keep
One of the commenters expressed concern over the new repo having its own history they don't want to lose. Well, that's the magic of git as a distributed VCS. You simply pull down all branches and tags and everything else to your local repo and then push that history up to the repo you are going to migrate.
git remote add origin1 https://github.com/blah/blah
git remote add origin2 https://github.com/blah/blah
git pull origin1
git push origin2
If you've created issues in both repos ... well that's screwed
Decide which repo has more important content, use that as the base, and port everything else into there. It's a "merge". good luck. The gh-issues-import.py script script posted by ibo.ezhe helps, but it doesn't restore comments on the issues. Feel free to improve it and send him a PullRequest (I did).
There's a Chrome Extension called Kamino that my colleague wrote. It's open source, and works extraordinarily well. It's more for copying issues individually, but he's looking at doing bulk copies as well.
Available here: https://chrome.google.com/webstore/detail/kamino/ffdebockfdjileaojbbccofhgncmioaf
Source code:
http://github.com/gatewayapps/kamino