How can collaborators push their changes to my repo in GitHub - eclipse

First I have created one project in Eclipse and committed to my GitHub using below commands:git init
git add .
git commit -m "first commit"
git remote add origin URI of my repo
git push -u origin master
Then I modified one file in Eclipse and committed to GitHub from Eclipse through creating remote and giving the remote URI of the repo.
I added my team member through add collaborator.
Then he downloaded my project and made a change in a file in Eclipse.
Now, how can he push that modified file to my GitHub repository from within Eclipse?
We have done one thing. He created a remote and gave the URI of my repo. But still we are unable to commit that file.

You need to add your colleague as a collaborator. This can be done in the desired GitHub repo via Settings > Collaborators (you need to type in your password again). Afterwards they have those permissions.
UPDATE
Sorry and good morning ;)
I overlooked that you already added your partner as a collaborator. Another possible reason for your situation could be in the Temporary interaction limits where you can, amongst others, limit the interaction with your repo to prior contributors.
If that doesn't help. Please add some more informations about your colleague's git logs.
UPDATE 2
#Rahul K regarding your comment (which you better add to your question, for faster recognition), your colleague first needs to integrate the remote changes via git pull origin master in order to be able to push his or her changes afterwards. But be aware that he or she might need to migrate any conflicts to files both of you applied changes to.
Best regards, David

I have resolved the issue by cloning the repo in my local folder, adding the project to eclipse and changing the file committed.
Before that you have to add that person as a collaborator. So that he/she can clone your repo using the command below:
git clone "Path to the repository"

This is an old question but I'll like to say this to help others that might still be facing this same issue.
I also faced this issue with a friend. I already made him a collaborator but he couldn't push. What we did to solve it was to clone the repo using the ssh url instead. Then we set up authentication in git with ssh. And we were able push successfully.
If you already cloned the repo with the usual HTTPS url, you can change the remote origin url using the git remote set-url origin <url> command but url here will be the ssh url.

Related

Rename Github Repository

I want to rename my Github repository. Say old name is foo and I want to rename to bar
I understand how to rename the repository on the github site.
Github also advises doing the following on the local machine:
In addition to redirecting web traffic, all git clone, git fetch, or git push operations targeting the previous location will continue to function as if made on the new location. However, to reduce confusion, we strongly recommend updating any existing local clones to point to the new repository URL. You can do this by using git remote on the command line:
git remote set-url origin new_url
Question: Do I need to change the repository directory on my local machine manually? Or if I do a git pull will it automatically change the name on my local machine.
I found some old answers to this question (before github made some changes) but, in reviewing the Github documentation and googling I can't find a satisfactory answer to my question. so this is NOT a duplicate question
Thanks in advance.
Going off of your comment, it seems that you are concerned about the name of the directory on your local machine. In this case, you are free to name it whatever you want - the name of the directory containing the repository has no impact on the repository itself, as long as the specified remote within .git is accurate.
For updating the remote on your local machine to match your new repository on GitHub, refer to GitHub User Documentation
If I understand correctly, you're wondering whether you need to change the old repository URL (git#github.com:user/foo.git) to new URL (git#github.com:user/bar.git)
In that case, the simple answer is yes you do need to change that.
As your git clone link is now changed to the new repository and if you create a new repository that happened to have the old repository name all git commands will confuse and push and pull wrong data to/from wrong repository.
As for your question does git pull will do that for you, unfortunately no as this remote URL is hardcoded in the .git/config file and you can simply edit that and replace the link with new one without running any git commands.
[remote "origin"]
url = git#github.com:user/foo.git
fetch = +refs/heads/*:refs/remotes/origin/*
Another approach is to rename the remote GitHub repository from command-line, using the new gh repo rename command (from gh 2.3.0, Dec. 2021)
cd /path/to/local/repo
gh rename newName
It does also update your remote 'origin' URL: no need for a git remote set-url origin https://github.com/<you>/<newName>, it is done for you.
The root folder of the repository can then be rename if you want (but it does not matter for Git)

Cancelling Version Control in Xamarin Studio while sharing with Github

initially i was trying to commit a project to github , then accidentally i didn't commit the project well, now am trying to remove Version Control and switch it again to Commit the project to Github.
I want to see this :
But am seeing this :
How can i Commit again , to github?
I recently just had this problem and asked the wonderful people at Github.
Note: I reset up a new repository, to commit to. I deleted the old one I had messed up. But still could not use Xamarin to Publish. Even after changing the remote connection in version control to the new repository.
This was the solution they provided me with:
From Github
I'm not familiar with the tool that your using to push to the repository but I can help you do this via the command line if that works for you?
Once we get the project pushed to GitHub I think should be able to clone it again to a fresh location on your computer and then link this into Xamarin hopefully.
The steps to push this from the command line would be:
Open the Terminal app and change directories to the location of the project on your local computer.
The command to change directories would be cd <full path to the projects location>. For example if your project was located in your documents folder
cd ~/Documents/projectname
Once there, you need to initiate the project for git version control, commit the project and link up the GitHub repository. To do that you can run the following commands one after the other:
git init
git add .
git commit -m `First commit`
git add remote origin https://github.com/yourrepository/project.git
The last step would be pushing to GitHub:
git push origin master
We have a help doc that has some instructions for this below:
https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
Let me know if you run into any trouble with that!
The only thing they did not mention was that you will be prompted for a username and password. This is the username and password for Github (not the token created for the repository)
Also in the linked documentation, in the above they use:
git push -u origin master
as the last step, I got an error when I did not include the -u
I also did not need to clone it.
The remote connection in Xamarin now links to this new repository. I have made and committed some changes to check.

Un-fork GitHub project into new GitHub project not associated with the original [duplicate]

How can I make GitHub forget or disassociate that my repo was originally a fork of another project?
I forked a project in GitHub. I can now see "forked from whatever/whatever". The parent repository "whatever/whatever" is no longer maintained. I have been allowed to continue use of the code base of the original repository to create an independent repository.
Is there a way to detach my project from the original repository?
Update Jan 2022:
Use the GitHub chatbot-virtual-assistant at https://support.github.com/contact?tags=rr-forks&subject=Detach%20Fork&flow=detach_fork
First answer:
You can contact github support and ask them to switch your repository to "normal mode".
On this page, "Commit was made in a fork" paragraph, it is explained that one has to go through support to switch. Therefore, it is likely that there is no way to do that by yourself (unless you destroy and recreate your repo which is explained before... if you do so be careful if you have tickets or a wiki attached to your project as they will be deleted!).
You could duplicate the forked repository to a new repository (without the fork dependency) from the GitHub UI, then remove the original forked one:
Sign in to GitHub
Select the + sign in the top right corner and select Import repository.
Import your forked repository. The new repository won't have the fork dependency.
Delete the original, forked repository in the repository settings.
NOTE: This approach will not preserve issues and pull requests.
Make sure you have all the important branches and tags on your local repo, delete the github repo, recreate the repository through usual means (no forking) and push the local repository back with git push --all. Note that if you have local branches that you don't want to publish, might be worth to create a temporary clean local clone for the operation.
However, this will also get rid of wiki and issues. As the wiki is in fact it's own repository, it can be handled similarly by cloning it and then recreating and pushing. The repo address is on wiki's Git Access page (git#github.com:user/repo.wiki.git).
This leaves issues. They can be exported through the API, but as far as I know, you can only create issues and comments with your person, so importing them perfectly is impossible.
So, if you need issues to be preserved, you should go through github support as Thomas Moulard suggests.
I got the similar problem, and ended up using this github help page to solve it. I didn't mind about the wiki and issues tracker as it was for my blog using a theme kindly developed by another user.
To detach a forked repo and use it as your own after several commits without losing the whole history:
git clone --bare git#github.com:user/forked_repo.git
Create a new empty reposity new-repository on the github website.
And push a mirrored version:
cd user.github.com.git/
git push --mirror git#github.com:user/new-repository.git
One can rename on github, the forked_repository with another name to keep it as backup and check updates if needed. Or simply delete it.
Renaming the new-repository to the original name does the job. As a side effect, your commits now appear in your history.
Log in to GitHub with your credentials.
Go to https://support.github.com/contact?tags=rr-forks&subject=Detach%20Fork&flow=detach_fork.
Choose "Detach", then enter the URL or repo name of the fork as your-user-name/repository-name, and answer the other questions of the virtual assistant.
You will get an email with a ticket number where you can check the status of your request. You will also be notified per email once your repo has been deforked.
Most repository settings will stay unchanged, including user permissions, stargazers, issues, PRs, discussions, etc.
Using the info from aurelien and Clayton, I was able to do this with the following:
$ git clone --bare https://github.com/my/forked_repo.git
<delete forked_repo on GitHub>
<recreate repo on GitHub using same name>
$ cd forked_repo.git
$ git push --mirror
Here's the documentation for git clone --bare:
Make a bare Git repository. That is, instead of creating <directory> and placing the administrative files in <directory>/.git, make the <directory> itself the $GIT_DIR. This obviously implies the -n because there is nowhere to check out the working tree. Also the branch heads at the remote are copied directly to corresponding local branch heads, without mapping them to refs/remotes/origin/. When this option is used, neither remote-tracking branches nor the related configuration variables are created.
Here's the documentation for git push --mirror:
Instead of naming each ref to push, specifies that all refs under refs/ (which includes but is not limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the remote repository. Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end. This is the default if the configuration option remote.<remote>.mirror is set.
Note: like the other git based answers, this will not copy over issues that are not part of the git repo such as the wiki and issues. Per Tapio:
The wiki is a separate git repo and can be handled in a similar fashion per Tapio. The address is: git#github.com:user/repo.wiki.git.
Issues can be exported via the GitHub API but there are issues recreating them since they can only be created by your user, so imports will lose information.
This only applies to GitHub Enterprise, not on github.com
Logged in to an account that has admin privileges:
Go to the repository that you need to detach: https://<ghe url>/<org>/<repo>
Click on the “Site Admin” rocket on the top right corner
Click "Collaboration" on the top menu bar
Click on “Network” on the left pane
Click on “Make Root” in the Network Structure pane
Accept
This was tested on GitHub Enterprise 2.9
If you do not need any past commits (I didn't in my case), you can just:
fork the project
make a local copy of the fork (I used my IDE to do that)
delete the git folder from your local copy
commit the project as you normally would a new project.
You can just delete the fork from your github account after. Took me all of one minute and worked like a charm.

Not able to checkin my code in github

This is my first day at using GITHUB and I am stuck with this issue despite lot of googling. Her are the steps which I have done so far
cloned a repository
git clone https://github.com/OfficeDev/Complete-Me-Code-Sample.git
Now since I don't want to corrupt the main branch, I created my own branch
git branch validation
Now I switched to my branch
git checkout validation
Now I made all my changes locally. After this I created the remote branch
git remote add validation https://github.com/OfficeDev/Complete-Me-Code-Sample.git
Now I try to uploaded all my code
git push complete-me-code-sample validation
it asks me for user name and password and then gives me an error
fatal: 'complete-me-code-sample' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
But isn't git open for everyone? or do I need to contact the owner of this project and ask for rights? if yes, what rights I should ask for?
At this point of time, I am finding too much information and its hard for me to proceed without doing a PHD.
Can you please tell me how I can checkin my code ... as well as point me to a resource which can teach me git without too much RTFM.
Your error is simple and it's git related, not github. Here it is:
Now I made all my changes locally. After this I created the remote branch
git remote add validation https://github.com/OfficeDev/Complete-Me-Code-Sample.git
This is not how you create a remote branch, in here you've added another origin (named validation), which basically is another clone of the same repo. You said that other repo is located at that address which is not true, as nothing exists there.
When you git push if the remote branch doesn't exist it is created by default, so if you simply skipped that step the branch would have been created fine.
The correct and optimised steps should have been:
git clone https://github.com/OfficeDev/Complete-Me-Code-Sample.git
// Creates and changed branch at the same time
git checkout -b validation
// You'll need to commit files first, just in case you missed that
git commit -am "my sample commit"
// Depending on how you set up the repo git push could be enough
git push origin validation
Try this and let me know how it went.

Getting started with GitHub and Eclipse (spring source toolsuite 2.7.1)

I am new with both Git and GitHub so please bear with me.
I have an empty repository on GitHub with an automatically created branch (gh-pages), which, I understand, is supposed to be used with GitHub's pages functionality.
Now what I would like to do is to create and eclipse project from which I could commit/push to this repository.
What is confusing me that I can't see any option to create a remote branch on github. I suppose pushing my source to gh-pages won't be a good idea. BTW, I also don't understand why the GitHub pages is feature is implemented as a branch? Aren't branches supposed to be merged with each other at some point. Clearly it wouldn't make any sense to merge github pages into my project. Wouldn't it be better to have a folder within my project for this purpose.
I googled and found this link but being a git noob I am not sure if that's what I want to do. I would like to use Eclipse as my primary interface to git and github only falling back to command line or other interfaces when there is no other option.
OK I think I have figured it out. Basically, what you need is to define a remote ref that need not exist before hand.
Create a project
Team->Share it to a local repository
In the repository view (Window->Show View-> Git -> Repositories) select the local repository and right click on remotes
Select new remote (configure push). Type origin in the remote name. Press OK
Change URL. Copy/paste the ssh uri from github. Select ssh protocol (make sure you have ssh key defined in eclipse SSH preferences, and uploaded to github)
Now the last part is to add Ref mapping. Click on Add.. in ref mapping section of screen. And enter refs/heads/master in both local and remote branches.
Or may be the refs/heads/master on both side isn't a good idea :)
I see, cloning a github repo that doesn't have gh-pages branch is simpler as it automatically creates this remote fetch spec
Remote Fetch Specification +refs/heads/*:refs/remotes/origin/*
Maybe this is what I need to enter in the step 6 above
Ok as it turned out the original idea of "refs/heads/master in both local and remote branch" was correct. Pushing with this configuration is showing my changes in git hub correctly. The second option on the other hand is failing silently.
Branches typically are used in the way you described, but nothing says they must be used that way. This is just the way github chose to let you manage your page content, and it works quite well. It's kind of similar to hosting multiple repos on one SVN server.
As for creating new repos, if you create a repo in github and then clone it, you'll have an empty repo locally that already points to github with a remote named "origin". This is a convenient way to start out, since you don't have to mess with adding a remote yourself. At this point, your repo has no commits and no branches in it. When you make the first commit, it will automatically establish a branch named "master". I don't know how eclipse is set up by default, but from the command line with default settings, you have to explicitly push new branches to a remote or else they won't get pushed at all. I.e. making the first commit and doing git push will just fail with a message like "No refs in common and none specified; doing nothing". Instead, you have to git push origin master to tell it to establish the "master" branch in remote "origin" (aka github). Thereafter, just a git push will work fine.
Hope that clears up some of your confusion.