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.
bash git macos bitbucket command-line-interface
add a comment |
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.
bash git macos bitbucket command-line-interface
can you change the last command in the script to sayecho 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
add a comment |
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.
bash git macos bitbucket command-line-interface
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
bash git macos bitbucket command-line-interface
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 sayecho 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
add a comment |
can you change the last command in the script to sayecho 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
add a comment |
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.
add a comment |
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.
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
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 19 at 14:47
Mark Adelsberger
19k11019
19k11019
add a comment |
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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