gitlab push is asking for github credentials? - github

I'm trying to push some files to a Gitlab project which I've already created in the GitLab GUI. So I'm trying to add some files to that project which already exists.
When I try:
git remote add origin https://git.doit.wisc.edu/my_user_name/my-website.git
I get this error:
error: remote origin already exists.
So I figured I could move on to the next step in the documentation - git branch.
Then I use:
git branch -M main
I was prompted with:
I entered my keychain password and all seemed fine but when I try to do:
git push -uf origin main
The terminal reads:
Username for 'https://github.com':
I put in my username and then get this error:
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
It seems like git is confusing gitlab and github. I'm trying to push to gitlab, not github. I'm so confused here. Is there something I'm missing in the first step?

No, Git's not confused here. When you said, git remote add origin… and Git reported an error, that means that the remote origin already exists for that repository. In this case, that remote points somewhere on GitHub, which you can see with git remote -v.
If you want to replace the existing URL for the origin remote, use git remote set-url origin https://git.doit.wisc.edu/my_user_name/my-website.git. If you want to create a new, differently named remote, then do git remote add gitlab https://git.doit.wisc.edu/my_user_name/my-website.git and push with git push gitlab main.
Note also that GitHub no longer allows you to use your account password to authenticate with Git. Instead, when prompted for a password, go to https://github.com/settings/tokens and create a token with the repo scope, and use that instead. However, in this case, since you're intending to push to GitLab, that shouldn't matter here.

Related

Can't push my Angular project to my github repo

I'm trying to save my Angular project to a repo on github and am getting an error saying
Please make sure you have the correct access rights and the repository exists.
I found several posts on here helping people get their SSH keys setup which I also did successfully. When I run git commit -m "some message" I get a response back saying there's nothing to commit and that the branch is clean. I switched the origin back and forth from the HTTPS and SSH links with git remote set-url origin (path) to see if that would make a difference but still get the same error about having access rights when running git push -u origin "main". I don't know what else to do or what I might be missing, can anyone help?
Another approach is to use GitHub CLI gh
install it
authenticate yourself (using a PAT - token) with gh auth login
(double-check with gh auth status)
create a new GitHub repository from your existing local repository with gh repo create
Regarding the last point:
cd /path/to/repo
gh repo create my-project --private --source=. --push
Replace my-project by a new GitHub repository name (or delete your existing one first)
Everything will be initialized and pushed!

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.

Push my first project from my Git to my online GitHub repository

I am a GitHub newbe. I've created a project on my computer in a folder named "SpettroCorpoNero", which contains a file "SpettroCorpoNero.ipynb".
Now I would like to initializate it into my GitHub account. For this purpose I wrote on my git (which is on Linux) the following lines of code:
git init (which should initializate my project)
git status (Which shows in red the new files I would like to replicate on my GitHub account)
git add SpettroCorpoNero.ipynb (which is the list of file to put in the "basket")
git commit -m "That's BlackBodySpectrum" (That looks like another basket to put in)
git push
And the code looks like working up to the second last line of code. Than the following message of error I've received
fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using
git remote add <name> <url>
and then push using the remote name
git push <name>
In order to sort it out, different attempts I've done, such as following that push with my nickname (which is Stefanovic80), as suggested in the message of error. But I failed in all of them and now I fill confused and disoriented.
Is there anyone who could fix this issue, please?
As the command says, you need to tell it where to push to, the default name is origin, the url is the same as the clone url of the repo.
git remote add origin https://GitHub.com/account/repo.git
You need to have a base repository on GitHub to push your repo into first using this route.
If you have the github-cli installed you can create the target repo and set the remote in one go by calling
gh repo create
from your local git repository. It will create the repo on GitHub and set up your local settings so you can push your repo straight after.
See also:
https://cli.github.com/manual/gh_repo_create
Simply, you just need to set up your remote. If you go to your remote repository (which is most likely empty), you'll see a URL which you can copy, which looks something like:
https://github.com/my-username/my-repo-name
Then, in command line, run the command
git remote add origin https://github.com/my-username/my-repo-name
You can substitute origin with whatever you like, but that will be the name of your remote connection.
Finally, you need to push main (or whatever the branch may be named) to the remote origin:
git push -u origin main

how to solve the requested URL returned error: 403 on bitbucket? and setup to push both on github and bitbucket?

I forked a repo from bitbucket for my internship test. I worked on it. then I did:
git init
hub create
now when i have to push to bit bucket and I want
to push also on github but i get this error:
unable to access 'https://bitbucket.org/aaa/bbb.git/': The requested
URL returned error: 403
I never used bitbucket and always github. I wanna be able to use both. The repo is open to everyone and I need to make a pull request to let them evaluate my code. I dont understand how need to install ssh key/bitbucket credentials on my local machine to access it. It seems confusing.
DOES anyone have any clue how to set up both bitbucket and github and fixing this error? I have to hand in by the end of the week and I am lost.
The repo is open to everyone
For pulling/cloning, yes, it is opened to everyone, not for pushing.
Only the owner/collaborators of the bitbucket.org/aaa/bbb.git can push to it, so if you want to make a pull request from a BitBucker repository, you need to push to to your fork, not the original repository.
You can push to multiple repositories:
git remote set-url --add --push origin https://github.com/<you>/<yourRepo>
git remote set-url --add --push origin https://bitbucket.org/<you>/<yourFork>
# Or, if you are using a registered SSH key to your BitBucket account
git remote set-url --add --push origin git#bitbucket.org:<you>/<yourFork>

Unable to git push julialang

I'm trying to get the latest julia master commit.
I instaled it via git clone, however, when I do
$ git push
It returns an exception:
fatal: remote error: You can't push to git://github.com/JuliaLang/julia.git
Use https://github.com/JuliaLang/julia.git
If I use the option given, git requires me a password.
It sounds like you probably don't actually want to push to the JuliaLang repository, but rather pull from it.
You git pull to fetch upstream changes and integrate them into your local repository. So, for example, to update and rebuild Julia, you would git pull && make clean && make from within julia's directory while on the master branch.
You would only git push if you were a contributor submitting changes. But even among contributors who have commit access, very few actually push directly to the master branch. Most create branches, submit those, and then open a pull request for a review. And for that workflow, you don't even need to be a contributor. You can "fork" the project on Github, and then push to your forked repository online. From there, you can open a pull request for review.
git:// doesn't allow for authentication.
ssh or https does.
In the case of https, it is asking for your GitHub username and password.
See more at "Git - the Protocols".
GitHub needs to know who you are, because only the owner (or a collaborator) has the right to push (while everybody can clone/pull from a public repo, which is why git:// works for cloning).
See "Permission levels for a user account repository".
Note: here github.com/JuliaLang is an organization, which means only the owner and members/teams can push to a repo declared in that organization.
Se more at "Permission levels for an organization repository".