fatal: remote already exists











up vote
0
down vote

favorite












As part of the development of a CI & CD flow for the company I work at, I am building a command line program (Bash script on OSX) that




  • creates a new local Git repo

  • adds some default branches to this repo

  • Then adds a new repo to Bitbucket using the next code:


gitUserName = Joris <-- provided by the user, this is an example
projectName = TestProject <-- provided by the user, this is an example
git remote add $projectName "https://bitbucket.org/$gitUserName/$projectName.git"



After running this command, I don't see the repository on my Bitbucket account on the website. When I try to re-run this command, it says the repository already exists.



Also, when I run git push $projectName master it says fatal: repository 'https://bitbucket.org/Joris/TestProject.git/' not found



This behavior seems inconsistent, and I have followed the Atlassian guide to set this up so I don't really understand why it doesn't add the repository as expected. I do realize that I can also just go on the BitBucket website and add the repository manually, but the purpose of my program is that it generates a fully set-up repository for a user based on as little commands as possible.










share|improve this question
























  • can you change the last command in the script to say echo git remote add $projectName "https://bitbucket.com/$gitUserName/$projectName.git" and see what happens?
    – Alex028502
    Nov 19 at 13:35










  • Hi! I tried and this is what it says: git remote add TestProject bitbucket.com/Joris/TestProject.git fatal: 'TestProject' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. This also seems surprising because when I the project I generated in Xcode (it's an iOS project I'm generating in git), it shows all the branches I added to the git.
    – Joris416
    Nov 19 at 13:41












  • looks like one says .com and one says .org
    – Alex028502
    Nov 19 at 13:54










  • Sorry that is just a silly reproduction error, corrected it in my question. it should be .org
    – Joris416
    Nov 19 at 13:59










  • I just noticed that running git remote -v also returns an empty respone
    – Joris416
    Nov 19 at 14:01















up vote
0
down vote

favorite












As part of the development of a CI & CD flow for the company I work at, I am building a command line program (Bash script on OSX) that




  • creates a new local Git repo

  • adds some default branches to this repo

  • Then adds a new repo to Bitbucket using the next code:


gitUserName = Joris <-- provided by the user, this is an example
projectName = TestProject <-- provided by the user, this is an example
git remote add $projectName "https://bitbucket.org/$gitUserName/$projectName.git"



After running this command, I don't see the repository on my Bitbucket account on the website. When I try to re-run this command, it says the repository already exists.



Also, when I run git push $projectName master it says fatal: repository 'https://bitbucket.org/Joris/TestProject.git/' not found



This behavior seems inconsistent, and I have followed the Atlassian guide to set this up so I don't really understand why it doesn't add the repository as expected. I do realize that I can also just go on the BitBucket website and add the repository manually, but the purpose of my program is that it generates a fully set-up repository for a user based on as little commands as possible.










share|improve this question
























  • can you change the last command in the script to say echo git remote add $projectName "https://bitbucket.com/$gitUserName/$projectName.git" and see what happens?
    – Alex028502
    Nov 19 at 13:35










  • Hi! I tried and this is what it says: git remote add TestProject bitbucket.com/Joris/TestProject.git fatal: 'TestProject' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. This also seems surprising because when I the project I generated in Xcode (it's an iOS project I'm generating in git), it shows all the branches I added to the git.
    – Joris416
    Nov 19 at 13:41












  • looks like one says .com and one says .org
    – Alex028502
    Nov 19 at 13:54










  • Sorry that is just a silly reproduction error, corrected it in my question. it should be .org
    – Joris416
    Nov 19 at 13:59










  • I just noticed that running git remote -v also returns an empty respone
    – Joris416
    Nov 19 at 14:01













up vote
0
down vote

favorite









up vote
0
down vote

favorite











As part of the development of a CI & CD flow for the company I work at, I am building a command line program (Bash script on OSX) that




  • creates a new local Git repo

  • adds some default branches to this repo

  • Then adds a new repo to Bitbucket using the next code:


gitUserName = Joris <-- provided by the user, this is an example
projectName = TestProject <-- provided by the user, this is an example
git remote add $projectName "https://bitbucket.org/$gitUserName/$projectName.git"



After running this command, I don't see the repository on my Bitbucket account on the website. When I try to re-run this command, it says the repository already exists.



Also, when I run git push $projectName master it says fatal: repository 'https://bitbucket.org/Joris/TestProject.git/' not found



This behavior seems inconsistent, and I have followed the Atlassian guide to set this up so I don't really understand why it doesn't add the repository as expected. I do realize that I can also just go on the BitBucket website and add the repository manually, but the purpose of my program is that it generates a fully set-up repository for a user based on as little commands as possible.










share|improve this question















As part of the development of a CI & CD flow for the company I work at, I am building a command line program (Bash script on OSX) that




  • creates a new local Git repo

  • adds some default branches to this repo

  • Then adds a new repo to Bitbucket using the next code:


gitUserName = Joris <-- provided by the user, this is an example
projectName = TestProject <-- provided by the user, this is an example
git remote add $projectName "https://bitbucket.org/$gitUserName/$projectName.git"



After running this command, I don't see the repository on my Bitbucket account on the website. When I try to re-run this command, it says the repository already exists.



Also, when I run git push $projectName master it says fatal: repository 'https://bitbucket.org/Joris/TestProject.git/' not found



This behavior seems inconsistent, and I have followed the Atlassian guide to set this up so I don't really understand why it doesn't add the repository as expected. I do realize that I can also just go on the BitBucket website and add the repository manually, but the purpose of my program is that it generates a fully set-up repository for a user based on as little commands as possible.







bash git macos bitbucket command-line-interface






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 at 13:58

























asked Nov 19 at 13:12









Joris416

2,41441939




2,41441939












  • can you change the last command in the script to say echo git remote add $projectName "https://bitbucket.com/$gitUserName/$projectName.git" and see what happens?
    – Alex028502
    Nov 19 at 13:35










  • Hi! I tried and this is what it says: git remote add TestProject bitbucket.com/Joris/TestProject.git fatal: 'TestProject' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. This also seems surprising because when I the project I generated in Xcode (it's an iOS project I'm generating in git), it shows all the branches I added to the git.
    – Joris416
    Nov 19 at 13:41












  • looks like one says .com and one says .org
    – Alex028502
    Nov 19 at 13:54










  • Sorry that is just a silly reproduction error, corrected it in my question. it should be .org
    – Joris416
    Nov 19 at 13:59










  • I just noticed that running git remote -v also returns an empty respone
    – Joris416
    Nov 19 at 14:01


















  • can you change the last command in the script to say echo git remote add $projectName "https://bitbucket.com/$gitUserName/$projectName.git" and see what happens?
    – Alex028502
    Nov 19 at 13:35










  • Hi! I tried and this is what it says: git remote add TestProject bitbucket.com/Joris/TestProject.git fatal: 'TestProject' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. This also seems surprising because when I the project I generated in Xcode (it's an iOS project I'm generating in git), it shows all the branches I added to the git.
    – Joris416
    Nov 19 at 13:41












  • looks like one says .com and one says .org
    – Alex028502
    Nov 19 at 13:54










  • Sorry that is just a silly reproduction error, corrected it in my question. it should be .org
    – Joris416
    Nov 19 at 13:59










  • I just noticed that running git remote -v also returns an empty respone
    – Joris416
    Nov 19 at 14:01
















can you change the last command in the script to say echo git remote add $projectName "https://bitbucket.com/$gitUserName/$projectName.git" and see what happens?
– Alex028502
Nov 19 at 13:35




can you change the last command in the script to say echo git remote add $projectName "https://bitbucket.com/$gitUserName/$projectName.git" and see what happens?
– Alex028502
Nov 19 at 13:35












Hi! I tried and this is what it says: git remote add TestProject bitbucket.com/Joris/TestProject.git fatal: 'TestProject' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. This also seems surprising because when I the project I generated in Xcode (it's an iOS project I'm generating in git), it shows all the branches I added to the git.
– Joris416
Nov 19 at 13:41






Hi! I tried and this is what it says: git remote add TestProject bitbucket.com/Joris/TestProject.git fatal: 'TestProject' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. This also seems surprising because when I the project I generated in Xcode (it's an iOS project I'm generating in git), it shows all the branches I added to the git.
– Joris416
Nov 19 at 13:41














looks like one says .com and one says .org
– Alex028502
Nov 19 at 13:54




looks like one says .com and one says .org
– Alex028502
Nov 19 at 13:54












Sorry that is just a silly reproduction error, corrected it in my question. it should be .org
– Joris416
Nov 19 at 13:59




Sorry that is just a silly reproduction error, corrected it in my question. it should be .org
– Joris416
Nov 19 at 13:59












I just noticed that running git remote -v also returns an empty respone
– Joris416
Nov 19 at 14:01




I just noticed that running git remote -v also returns an empty respone
– Joris416
Nov 19 at 14:01












2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










The git remote add documentation says that the command adds a remote to the local repo. This terminology is, IMO, a bit off; it would better to say it adds a remote configuration to the local repository (i.e. configures the repo to access a remote). This does not actually create the remote repo; that must be done separately.



In the case of bitbucket, the "normal" thing to do is to go to the website and create the repo through their UI. Because you're trying to automate things, you don't want to do that; so in that case, you would need to use the BitBucket REST API, which is documented here: https://developer.atlassian.com/server/bitbucket/reference/rest-api/



The "Core API" section talks about repositories and permissions, so you should be able to script out requests to (if necessary) check if the repo exists and set it up if it doesn't. You'll just need a way for your script to send HTTP requests and receive the responses.






share|improve this answer




























    up vote
    0
    down vote













    In your machine:



    Create repo:



    git init 


    Add branches:



    git checkout -b branchX
    git checkout -b branchY
    git checkout -b branchZ


    In Bitbucket website:



    Create new repository named TestProject, allow write permissions to user Joris in settings and save. Finally copy the url of the repository, this must be something like bitbucket.mydomain:port/nameofproject/testproject.git (Notice this is all in lowcase)



    In your machine:



    git remote add origin theURL
    git push origin *:*
    git push origin --tags


    The last is the command to push all your local repo, this will overwrite the history and tags in your remote repo, but since is a new repo it doesn't matter.






    share|improve this answer























    • Hi Johan, Thanks for your quick response. I should add that I am developing a command line program for Continuous Integration & Continuous Deliver Xcode Projects. This means that the purpose of what I'm doing is to let a user run one command in the CLI, and that my program then sets up everything for them, including a remote bitbucket git repo. They shouldn't have to go to the website to do anything by hand. Can this be done?
      – Joris416
      Nov 19 at 13:44












    • You need to use the rest api from attlasian directly, Maybe you can find useful [community.atlassian.com/t5/Git-questions/… (community.atlassian.com/t5/Git-questions/… ) and [developer.atlassian.com/server/bitbucket/reference/rest-api/] (developer.atlassian.com/server/bitbucket/reference/rest-api)
      – Johan Alexis Duque Cadena
      Nov 19 at 15:41











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375409%2ffatal-remote-repository-already-exists%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    The git remote add documentation says that the command adds a remote to the local repo. This terminology is, IMO, a bit off; it would better to say it adds a remote configuration to the local repository (i.e. configures the repo to access a remote). This does not actually create the remote repo; that must be done separately.



    In the case of bitbucket, the "normal" thing to do is to go to the website and create the repo through their UI. Because you're trying to automate things, you don't want to do that; so in that case, you would need to use the BitBucket REST API, which is documented here: https://developer.atlassian.com/server/bitbucket/reference/rest-api/



    The "Core API" section talks about repositories and permissions, so you should be able to script out requests to (if necessary) check if the repo exists and set it up if it doesn't. You'll just need a way for your script to send HTTP requests and receive the responses.






    share|improve this answer

























      up vote
      1
      down vote



      accepted










      The git remote add documentation says that the command adds a remote to the local repo. This terminology is, IMO, a bit off; it would better to say it adds a remote configuration to the local repository (i.e. configures the repo to access a remote). This does not actually create the remote repo; that must be done separately.



      In the case of bitbucket, the "normal" thing to do is to go to the website and create the repo through their UI. Because you're trying to automate things, you don't want to do that; so in that case, you would need to use the BitBucket REST API, which is documented here: https://developer.atlassian.com/server/bitbucket/reference/rest-api/



      The "Core API" section talks about repositories and permissions, so you should be able to script out requests to (if necessary) check if the repo exists and set it up if it doesn't. You'll just need a way for your script to send HTTP requests and receive the responses.






      share|improve this answer























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        The git remote add documentation says that the command adds a remote to the local repo. This terminology is, IMO, a bit off; it would better to say it adds a remote configuration to the local repository (i.e. configures the repo to access a remote). This does not actually create the remote repo; that must be done separately.



        In the case of bitbucket, the "normal" thing to do is to go to the website and create the repo through their UI. Because you're trying to automate things, you don't want to do that; so in that case, you would need to use the BitBucket REST API, which is documented here: https://developer.atlassian.com/server/bitbucket/reference/rest-api/



        The "Core API" section talks about repositories and permissions, so you should be able to script out requests to (if necessary) check if the repo exists and set it up if it doesn't. You'll just need a way for your script to send HTTP requests and receive the responses.






        share|improve this answer












        The git remote add documentation says that the command adds a remote to the local repo. This terminology is, IMO, a bit off; it would better to say it adds a remote configuration to the local repository (i.e. configures the repo to access a remote). This does not actually create the remote repo; that must be done separately.



        In the case of bitbucket, the "normal" thing to do is to go to the website and create the repo through their UI. Because you're trying to automate things, you don't want to do that; so in that case, you would need to use the BitBucket REST API, which is documented here: https://developer.atlassian.com/server/bitbucket/reference/rest-api/



        The "Core API" section talks about repositories and permissions, so you should be able to script out requests to (if necessary) check if the repo exists and set it up if it doesn't. You'll just need a way for your script to send HTTP requests and receive the responses.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 19 at 14:47









        Mark Adelsberger

        19k11019




        19k11019
























            up vote
            0
            down vote













            In your machine:



            Create repo:



            git init 


            Add branches:



            git checkout -b branchX
            git checkout -b branchY
            git checkout -b branchZ


            In Bitbucket website:



            Create new repository named TestProject, allow write permissions to user Joris in settings and save. Finally copy the url of the repository, this must be something like bitbucket.mydomain:port/nameofproject/testproject.git (Notice this is all in lowcase)



            In your machine:



            git remote add origin theURL
            git push origin *:*
            git push origin --tags


            The last is the command to push all your local repo, this will overwrite the history and tags in your remote repo, but since is a new repo it doesn't matter.






            share|improve this answer























            • Hi Johan, Thanks for your quick response. I should add that I am developing a command line program for Continuous Integration & Continuous Deliver Xcode Projects. This means that the purpose of what I'm doing is to let a user run one command in the CLI, and that my program then sets up everything for them, including a remote bitbucket git repo. They shouldn't have to go to the website to do anything by hand. Can this be done?
              – Joris416
              Nov 19 at 13:44












            • You need to use the rest api from attlasian directly, Maybe you can find useful [community.atlassian.com/t5/Git-questions/… (community.atlassian.com/t5/Git-questions/… ) and [developer.atlassian.com/server/bitbucket/reference/rest-api/] (developer.atlassian.com/server/bitbucket/reference/rest-api)
              – Johan Alexis Duque Cadena
              Nov 19 at 15:41















            up vote
            0
            down vote













            In your machine:



            Create repo:



            git init 


            Add branches:



            git checkout -b branchX
            git checkout -b branchY
            git checkout -b branchZ


            In Bitbucket website:



            Create new repository named TestProject, allow write permissions to user Joris in settings and save. Finally copy the url of the repository, this must be something like bitbucket.mydomain:port/nameofproject/testproject.git (Notice this is all in lowcase)



            In your machine:



            git remote add origin theURL
            git push origin *:*
            git push origin --tags


            The last is the command to push all your local repo, this will overwrite the history and tags in your remote repo, but since is a new repo it doesn't matter.






            share|improve this answer























            • Hi Johan, Thanks for your quick response. I should add that I am developing a command line program for Continuous Integration & Continuous Deliver Xcode Projects. This means that the purpose of what I'm doing is to let a user run one command in the CLI, and that my program then sets up everything for them, including a remote bitbucket git repo. They shouldn't have to go to the website to do anything by hand. Can this be done?
              – Joris416
              Nov 19 at 13:44












            • You need to use the rest api from attlasian directly, Maybe you can find useful [community.atlassian.com/t5/Git-questions/… (community.atlassian.com/t5/Git-questions/… ) and [developer.atlassian.com/server/bitbucket/reference/rest-api/] (developer.atlassian.com/server/bitbucket/reference/rest-api)
              – Johan Alexis Duque Cadena
              Nov 19 at 15:41













            up vote
            0
            down vote










            up vote
            0
            down vote









            In your machine:



            Create repo:



            git init 


            Add branches:



            git checkout -b branchX
            git checkout -b branchY
            git checkout -b branchZ


            In Bitbucket website:



            Create new repository named TestProject, allow write permissions to user Joris in settings and save. Finally copy the url of the repository, this must be something like bitbucket.mydomain:port/nameofproject/testproject.git (Notice this is all in lowcase)



            In your machine:



            git remote add origin theURL
            git push origin *:*
            git push origin --tags


            The last is the command to push all your local repo, this will overwrite the history and tags in your remote repo, but since is a new repo it doesn't matter.






            share|improve this answer














            In your machine:



            Create repo:



            git init 


            Add branches:



            git checkout -b branchX
            git checkout -b branchY
            git checkout -b branchZ


            In Bitbucket website:



            Create new repository named TestProject, allow write permissions to user Joris in settings and save. Finally copy the url of the repository, this must be something like bitbucket.mydomain:port/nameofproject/testproject.git (Notice this is all in lowcase)



            In your machine:



            git remote add origin theURL
            git push origin *:*
            git push origin --tags


            The last is the command to push all your local repo, this will overwrite the history and tags in your remote repo, but since is a new repo it doesn't matter.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 19 at 15:39

























            answered Nov 19 at 13:36









            Johan Alexis Duque Cadena

            8819




            8819












            • Hi Johan, Thanks for your quick response. I should add that I am developing a command line program for Continuous Integration & Continuous Deliver Xcode Projects. This means that the purpose of what I'm doing is to let a user run one command in the CLI, and that my program then sets up everything for them, including a remote bitbucket git repo. They shouldn't have to go to the website to do anything by hand. Can this be done?
              – Joris416
              Nov 19 at 13:44












            • You need to use the rest api from attlasian directly, Maybe you can find useful [community.atlassian.com/t5/Git-questions/… (community.atlassian.com/t5/Git-questions/… ) and [developer.atlassian.com/server/bitbucket/reference/rest-api/] (developer.atlassian.com/server/bitbucket/reference/rest-api)
              – Johan Alexis Duque Cadena
              Nov 19 at 15:41


















            • Hi Johan, Thanks for your quick response. I should add that I am developing a command line program for Continuous Integration & Continuous Deliver Xcode Projects. This means that the purpose of what I'm doing is to let a user run one command in the CLI, and that my program then sets up everything for them, including a remote bitbucket git repo. They shouldn't have to go to the website to do anything by hand. Can this be done?
              – Joris416
              Nov 19 at 13:44












            • You need to use the rest api from attlasian directly, Maybe you can find useful [community.atlassian.com/t5/Git-questions/… (community.atlassian.com/t5/Git-questions/… ) and [developer.atlassian.com/server/bitbucket/reference/rest-api/] (developer.atlassian.com/server/bitbucket/reference/rest-api)
              – Johan Alexis Duque Cadena
              Nov 19 at 15:41
















            Hi Johan, Thanks for your quick response. I should add that I am developing a command line program for Continuous Integration & Continuous Deliver Xcode Projects. This means that the purpose of what I'm doing is to let a user run one command in the CLI, and that my program then sets up everything for them, including a remote bitbucket git repo. They shouldn't have to go to the website to do anything by hand. Can this be done?
            – Joris416
            Nov 19 at 13:44






            Hi Johan, Thanks for your quick response. I should add that I am developing a command line program for Continuous Integration & Continuous Deliver Xcode Projects. This means that the purpose of what I'm doing is to let a user run one command in the CLI, and that my program then sets up everything for them, including a remote bitbucket git repo. They shouldn't have to go to the website to do anything by hand. Can this be done?
            – Joris416
            Nov 19 at 13:44














            You need to use the rest api from attlasian directly, Maybe you can find useful [community.atlassian.com/t5/Git-questions/… (community.atlassian.com/t5/Git-questions/… ) and [developer.atlassian.com/server/bitbucket/reference/rest-api/] (developer.atlassian.com/server/bitbucket/reference/rest-api)
            – Johan Alexis Duque Cadena
            Nov 19 at 15:41




            You need to use the rest api from attlasian directly, Maybe you can find useful [community.atlassian.com/t5/Git-questions/… (community.atlassian.com/t5/Git-questions/… ) and [developer.atlassian.com/server/bitbucket/reference/rest-api/] (developer.atlassian.com/server/bitbucket/reference/rest-api)
            – Johan Alexis Duque Cadena
            Nov 19 at 15:41


















             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375409%2ffatal-remote-repository-already-exists%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            Refactoring coordinates for Minecraft Pi buildings written in Python