Karan Kumar
Karan Kumar

Reputation: 287

How to delete url in git

I am pushing data to github. When I push data i am facing problem.I am pushing data using this.

git init
touch README.md
git add .
git commit -m "initial commit"
git remote add origin https://github.com/YourAccount/firstPush.git
git push -u origin master

Actuall I run git remote add origin https://github.com/YourAccount/firstPush.git this command wrong. When I again push data with correct path I got error

fatal: remote origin already exists.

Upvotes: 7

Views: 12828

Answers (3)

Sol
Sol

Reputation: 11

Find the .gitconfig file in your local computer. Open it with notepad and delete the urls from there.

The following command will show you where your url is living.

git config --list --show-origin

Upvotes: 0

Two
Two

Reputation: 670

Use this command

$ git remote set-url <remote repository url>

Upvotes: 1

hjpotter92
hjpotter92

Reputation: 80653

You can follow any of the following 3 methods:

  1. Remove the old origin and readd the correct one:

    git remote remove origin
    git remote add origin <correct address>
    
  2. Update the existing remote links:

    git remote set-url origin <correct url>
    

    you can optionally provide --push to the above command.

  3. Update the remote section of your .git/config file:

    [remote "origin"]
        url = <correct url>
        fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
        remote = origin
        merge = refs/heads/master
    

You can also refer to git documentation for the git remote commands.

Upvotes: 12

Related Questions