Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete url in git

Tags:

git

git-remote

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.
like image 342
Karan Kumar Avatar asked Sep 19 '15 06:09

Karan Kumar


People also ask

How do I remove remote URL from GitHub?

Use the git remote rm command to remove a remote URL from your repository.

How do I change the URL of my git repository?

In order to change the URL of a Git remote, you have to use the “git remote set-url” command and specify the name of the remote as well as the new remote URL to be changed. For example, let's say that you want to change the URL of your Git origin remote.


1 Answers

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.

like image 144
hjpotter92 Avatar answered Sep 28 '22 07:09

hjpotter92