1

Recently I made new project and with new repository on github.

But when I push to the new repository, it also tries to push to old repository which I never connected with the new project, Like this:

enter image description here

The old repo is in the same Github account with new repo, but it is connected to another project of mine (hence fail to push)

When I check my remote on my new project, it shows these

enter image description here

I tried to delete & change the url with set-url, or delete ... But the old url is still there

My .git/config file is

enter image description here

it doesn't have old repo url.

Pushing to new project is actually working well, but everytime I push to new one it always tries to push to old one & fails

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Joy
  • 87
  • 1
  • 2
  • 12

3 Answers3

1

This also happened to my Xcode project, so after digging in again I found out my own answer. The problem was on the global file.

How can i delete git user property? This answer helped me.

git config --global --unset remote.origin.url OLD.REPO.URL

This finally solved the problem!

Joy
  • 87
  • 1
  • 2
  • 12
0

The output from git remove -v shows origin set to push to both the old and new repositories. Assuming you don't want this, you can try removing origin completely, then adding it back again with the correct settings:

git remote rm origin
git remote add origin https://github.com/USERNAME/REPOSITORY.git

and then

git push -u origin master
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • Hi, thanks for the answer. Unfortunately, I tried this, but this didn't work. `git remote rm origin` removed my new repo url only, so when I put `git remote set-url origin (new repo)` there were still two urls remain. Seemed like the old repo url wasn't affected by all these `git remote` commands. – Joy Aug 24 '17 at 02:35
  • `git remote add origin` doesn't work, saying `fatal: remote origin already exists.` `git remote rm origin` doesn't remove my old repo url. – Joy Aug 24 '17 at 03:16
  • Can you try `git remote remove origin`? What version of Git are you using? – Tim Biegeleisen Aug 24 '17 at 03:19
  • It's the same command, right? At least for me. I tried it before but result was the same. Version is git version 2.11.0 (Apple Git-81). – Joy Aug 24 '17 at 03:21
  • After running `git remote rm origin` try running `git remote -v` ... what do you now see? – Tim Biegeleisen Aug 24 '17 at 03:25
  • It removes my new repo url, shows `old repo (fetch)` `old repo (push)`. – Joy Aug 24 '17 at 03:28
  • My answer should have worked. Are you certain that the old remote is really called `origin`? Could there be any whitespace in the name? – Tim Biegeleisen Aug 24 '17 at 03:40
  • I know it should have worked... I searched for everything but none of them worked. The second image I posted shows that the old remote name is origin, but I haven't thought about whitespace. Is there anyway to check that? – Joy Aug 24 '17 at 03:45
  • But again I think the name of old repo is also origin, because 'git remote add origin doesn't work, saying fatal: remote origin already exists.' – Joy Aug 24 '17 at 03:49
0

Reading from your image error and hint. you can follow this way

  1. create a local branch
  2. checkout in local branch
  3. change your files or add files what ever want
  4. commit there
  5. than push it to master branch

you can do 1 and 2 by git checkout - b local_branch and then commit and push command.

R.A.Munna
  • 1,699
  • 1
  • 15
  • 29
  • Pushing to the old repository is not what I want. Git with this new project shouldn't be pushed to that old repo. – Joy Aug 24 '17 at 13:25