github: push project from eclipse to remote repository for first time and no credentials asked - eclipse

I have a project in eclipse in my local workspace.
I created a github public account, created a remote repository, copied the HTTPS clone URL.
Then cloned the Git repository to create my local repository, and shared the project with the local repository, configured Git for merge and fetch, and committed my changes to local repository, and then successfully pushed the committed changes to the remote repository. I can see the changes in remote repository.
There was username and password fields when I tried to clone the git repository, but I left as blank, and did not give my github account details.
Question: I am so surprised that nowhere I was prompted for a username and password. Does this mean, anybody can push changes to my remote repository? If not, How was I recognized?

then successfully pushed the committed changes to the remote repository
That means you must have logged in to GitHub at one point: even without any repo, you can put your GitHub credentials in the GitHub for Windows/Mac (assuming you are using that GUI)
Once logged in, any repo you are adding can be push to if the GUI detects that your initial credentials match the owner of that repo.
And as Paul Betts would insist, said credentials are cached.

Related

Link the Heroku cloned project with another existing Github repository of User

I have cloned sample project from Heroku:
git clone https://github.com/heroku/node-js-getting-started.git
cd node-js-getting-started
When I run git remote -v I get:
Now I want to link my existing GitHub repository (i.e.: https://github.com/user/my-repo) with the cloned project.
My main goal is, if I push anything to GitHub, I want the changes to be happened in both places, the Heroku repository as well as my repository (i.e: https://github.com/user/my-repo).
I have cloned sample project from Heroku
You have cloned a sample project from GitHub. You won't have permission to push to that repository, but if you did, you'd be pushing to GitHub, not to Heroku.
Now I want to link my existing GitHub repository (i.e.: https://github.com/user/my-repo) with the cloned project.
Assuming that repository is empty, simply change the URL your remote points to:
git remote set-url origin https://github.com/user/my-repo.git
Now your origin remote points to your own repository.
My main goal is, if I push anything to GitHub, I want the changes to be happened in both places, the Heroku repository as well as my repository (i.e: https://github.com/user/my-repo).
Normally, you'd be able to enable GitHub integration and configure pushes to your GitHub main branch to trigger a build on Heroku, but that feature is currently disabled while Heroku investigates a security breach.
Until that gets resolved I suggest you add a second remote:
Install the Heroku CLI
Log into Heroku with heroku login
Add a remote with heroku git:remote -a YOUR_APP
Then verify that you can push to both remotes individually:
git push origin main
git push heroku main
You can continue to deploy that way, and I suggest you do.
But if you really want to, you can add your Heroku push URL to your origin remote so git push origin main actually pushes to GitHub and Heroku. Heroku outputs useful build information when you push to it and I'm not sure how well the two outputs will be kept separate if you do this.

difference btw local account and github account?

What is the difference between the local account that I set in git bash with git config --global user.name and my actual github account login. I have a test repo, in there I have added a few collaborators. When I push to the repo, the history will show my local name and not my github account username. How come ?
GitHub is not git. GitHub is a remote repository management application. It has its own authentication and account system. You can push git repositories to it so that they can be shared and controlled.
The "local" variables that you set through git config are ways to make it faster to set the author of a commit.
There is nothing stopping you from pushing commits authored by someone who is "not you" to a GitHub remote that you control. I believe they will be associatively "linked" if the emails match, but it's not enforced or required.

Pushing files from one account to other in github

Iam trying to push some changes to other account from another account but it is giving me permission error.I checked the github settings but everything there seems to be right.Can anybody help me with this?
EDIT:
I tried changing my user name and email too still it is giving same error
Some info about the transfer process which might help you
When a repository is transferred between two user accounts, issue assignments are left intact. When you transfer a repository from a user account to an organization, issues assigned to members in the organization remain intact, and all other issue assignees are cleared. Only owners in the organization are allowed to create new issue assignments. When you transfer a repository from an organization to a user account, only issues assigned to the repository's owner are kept, and all other issue assignees are removed.
If the transferred repository contains a GitHub Pages site, then links to the Git repository on the Web and through Git activity are redirected. However, we don't redirect GitHub Pages associated with the repository.
All links to the previous repository location are automatically redirected to the new location. When you use git clone, git fetch, or git push on a transferred repository, these commands will redirect to the new repository location or URL. However, to avoid confusion, I 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
Add the collaborator from the initial account (the git account having the repo) and the second account can accept the invitation to be a collaborator
This allows you to change and push the code from different Id also.

How can collaborators push their changes to my repo in GitHub

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.

EGit Local vs. Remote repositories

I'm new to git and am wrapping my head around how I'm supposed to be using git and egit. From the egit tutorial, I have setup a respository on GitHub, pushed my Eclipse projects to the remote GitHub repository from my local workspace, I can push changes to GitHub, switch branches, see the updates on GitHub, etc. This all makes sense.
Looking at the Git Repository explorer, I have a listing of "Local" branches and have no "Remote Tracking" branches and I have no "Remotes" listed. When I create a branch from a local branch, the egit dialog indicates "You are creating a branch based on a local branch" and suggests that I should be making a branch from a remote tracking branch.
So my question is, am I correctly using egit?
Should I just continue pushing changes to the remote GitHub repository? If so, what happens once I share the project and other developers clone the repository and start making changes to the remote repository?
Or should I now ditch the local repository and setup a new remote repository by cloning the existing GitHub repository that I initially created from my workspace?
Or do I create a new Push and Fetch "Remote" for my existing git repository?
Or something else?
Confused.
Since you created the repo on your local system and then pushed it to github without creating a remote you don't have a remote at hand. A remote is simply a short alias for the remote repository's URL. To fix this create a remote and a push and fetch configuration from the repositories view. In order to populate remote tracking branches in your local repo you need to run fetch once. As soon as this is done you can use "Push to upstream" instead of the more complex Team > Push... dialog which allows to define all parameters on the fly. When using native git command line you'll find the same concepts implemented there:
with
"$ git push [url] [refspec]" (e.g. "$ git push https://github/user/myrepo.git master:master")
you pass all parameters explicitly, this is similar to Team > Push... in EGit
with
"$ git push [remote]" (e.g. "$ git push origin")
you push to the repository defined by the configuration parameters of the given remote (check .git/config to see these parameters or open repository configuration from egit preference in Eclipse), this is similar to Team > Push to upstream in EGit. Usually the refspec used in this way is implicitly configured when creating a local branch based on a remote tracking branch. It's also possible to add this configuration later but since this is more
tedious manual configuration the other way is more handy.
If you clone a remote repository the repository you cloned from is stored as remote "origin" in your clone. This way you can skip configuring the remote manually. This is only needed if the repository is born when you create it from scratch.
The "Branching" section of the Egit User Guide can help:
There is no obligation to create a local branch which would be named like a remote tracking branch (see "Having a hard time understanding git-fetch" to have a good understanding of "remote tracing branches).
You can create as many local branches (i.e. branches that you won't necessary push anywhere) as you want/need.
But if you don"t see any remote branch, maybe you didn't fetch that GitHub repo in the first place: see Fetching.