Direct link/access of a githib repos from another github account? - github

This might be a naive question. I have couple of repos on my github account (say on account A). For the purpose of publications I should push my projects to someone else's github account (account B) and provide the other repos link in the publication.
I would like to (1) keep the credit of my codes even when repos are in his account, (2) do not update account B if repos in A changed. Account B will not do any development on code, and only its used for providing it's URL in publications.
My question is that, is there anyway to have a direct link from my repos in account B to account A? I think with fetching or a basic mirroring, account B should keep updating the original repos regularly, but I want to avoid it.
What I want is either:
1) a direct link that when clients click on it on account B, they will be directed to my repos on account A.
2) or if the above is not possible, by cloning from account B, clients get files directly from repos on account A.
Any ideas if it (or anything similar to it) is possible? Thanks.

Git has something for this exact thing - it's called submodules. From the Git website:
Submodules allow you to keep a Git repository as a subdirectory of another Git repository. This lets you clone another repository into your project and keep your commits separate.
Check out the answer to this question - it has a bit more detail (credit to #Jefromi): https://stackoverflow.com/a/4377799/1442788

Related

Merge two github accounts

Is it possible to merge two GitHub accounts into one?
I had one work account but would like to merge into a personal one.
I found some details about transferring ownership of the own repos which will merge all commit history etc.
Could anyone please confirm if it will transfer all commit history for any contributions made to another third party repos?
What will happen in the third party repos where I have made contributions from work account after the work account is deleted?
That is what describes "Merging multiple personal accounts"
And its repository transfer process (from the account you want to delete to the account you want to keep) should transfer issues, pull requests, and wikis.
You will need to add the email address you used to author the commits (of the old account) to the account you're keeping.
That way, your old contributions will be preserved.
I logged a support ticket with github and below is the summary:
After deleting work account and following steps as mentioned https://docs.github.com/en/repositories/creating-and-managing-repositories/transferring-a-repository did not bring contributions across to the personal account.
As work account was deleted - it started showing as a ghost account.
The commits made through work account were as from the personal acccount but contribution history (PR or any reviews) didn't come across to the personal account.
So make sure you think of above steps before removing any of your Github account.
Below were responses from Github:
As pull requests, issues and all activity in the GitHub web UI excluding commits are directly tied to the account that created them, they will not be counted on the new account even if you add the old account's email address to the new account.
Pull requests are replaced with the ghost user when the account is deleted. On the other hand, we read the email address from the metadata stored inside a commit and attempt to match commits up with a user account, so those that meet the contribution criteria will be counted on the new account.

fork repo from personal account into organisation acount

I developed a project on my personal github account.
I'm a member (not owner) of an organisation and would like to fork my project in the organisational account, such that the organisation can help maintain it in the future.
How is this done best?
As far as I understood, when I transfer or perform an import into the organisation account from my personal repo, I loose the project in my account which I don't want.
I'm sorry in case this is a "stupid" question - I'm pretty new to git and github...
Any reason not to transfer it, then fork it again back to your account?
That way you can still raise pull requests from your person fork back to the main one.
Thanks for all the answers.
According to the github support team:
Importing is intended to bring code from outside GitHub into GitHub, so that wouldn't be suitable.
and
Transferring would indeed mean you no longer had the repository on your account.
The solution for me was:
requested owner priviledges for the organisation (in case that would not be possible, ask an owner to perform the following steps)
went to the repository which I wanted to fork (In my case, this was on my personal profile and I was logged in with my personal account. I don't have any login informations for the organisation account)
pressed fork and there was a pop-up, asking for where to fork this repo
selected the organisation
I hope to help others in the future with this :-)
you should be able to import without loosing the project in your personal account.
This is what IMO makes the difference between transfer and import.
Be sure to login with your organizational account, if you have two separate accounts

Github transfer contributions from one account to another

I have googled it a lot but didn't find any clear answer if it possible and how to do it.
I have an account from which I have contributions to a private repo. I don't have any repositories.
I want all those contributions to go to my new account (There I have repositories).
Is that possible? Do I still have access to that private repo after transfer the contributions?
You would need to rewrite commits which would create new hashes (the committer's name is part of the data used to calculate the hash).
This would mean all commits that reference these commits (the parent commits also being part of the data used to calculate the hash) would also need to be regenerated (rebase allows this to be done in bulk).
All of this would require forcing pushes as well (so all other contributor's local repositories are going to be impacted).
Even if github can automate some of this, it is a massive impact.
TL;DR: yes, but you probably should accept it is hard to rewrite history.
Guessing from the tags I assume you're talking about GitHub accounts. GitHub calculates contributions based on the author email address used in Git commits, and if there is a GitHub account that uses this email address, your GitHub user name shows up as a contributor. That said, you can associate multiple email addresses with a single GitHub account. So if you unregister your current email address from your old GitHub account, and register the same email address for your new GitHub account, existing contributions will show under your new GitHub account.
Do I still have access to that private repo after transfer the contributions?
That's a totally different question, and the answer depends on whether your new GitHub account was given access to the private repository. The GitHub permissions system is based on the GitHub user name, not on registered email addresses.

github: transfer ownership and fork

I've transfered ownership of one of my github repositories (rdmuller/docToolchain) to an organisation (docToolchain/docToolchain).
So far, so good. All old URLs are redirected to the new location. Perfect.
But how do I now fork this repository? I fear that, if I fork it, a fork with the name of the old repository (rdmueller/docToolchain) will be created and the redirect will be broken this way...
how can I avoid this?
So, I guess I found a workaround.
suppose you have a repository
user1/repo1
You now want to transfer ownership to org1 and create a fork of it in your account user1.
The problem is that, if you create this fork directly, there will be again a repo called user1/repo1 and github is not able to redirect URLs to the old repository to org1/repo1
Solution:
transfer ownership from user1/repo1 to org1/repo1
create a temporary organisation org2
fork org1/repo1 to org2/repo1
rename org2/repo1 to something like org2/repo1-fork
transfer ownership from org2/repo1-fork to user1/repo1-fork
this seems to do the trick.
Since May 2020, Ben Balter (Senior Product Manager working on Community and Safety at #GitHub) mentions in his tweet:
We're beta testing a new GitHub feature that allows you to invite someone to manage your open source projects in the event that you are unable able to do so yourself.
If you'd like early access, reply or DM with your GitHub handle and I can add you.
See "Maintaining ownership continuity of your user account's repositories"
You can invite someone to manage your user owned repositories if you are not able to.
We recommend inviting another GitHub user to be your successor, to manage your user owned repositories if you cannot. As a successor, they will have permission to:
Archive your public repositories.
Transfer your public repositories to their own user owned account.
Transfer your public repositories to an organization where they can create repositories.

How to merge several Github users?

I am newbie github users and mistakenly created two github user accounts. I'm wondering how can we merge two github users account into one, including their corresponding repositories? any idea?
A quick something search will give you this:
Transfer any repositories from the account you want to delete to the account you want to keep. Issues, pull requests, and wikis are transferred as well. Verify the repositories exist on the account you want to keep.
Update the remote URLs in any local clones of the repositories that were moved.
Delete the account you no longer want to use.