Reputation: 1244
I was following this steps to succesfully manage 2 environments in Heroku, and how to set that up in git. Everything worked fine, but now I've got a problem with git showing me old name of a remote, and can't delete it.
Before the tutorial, I had only two remotes, origin
and heroku
. But as stated, recommended convention names are staging
and production
, so I renamed the remote heroku
to staging
via the .git/config
file. In that change, I had to follow this instructions: "Cannot update paths and switch to branch at the same time" because the renamed staging
remote wouldn't show any branches. The fetch made the trick.
Push/pulls and deploys are working very nice now with both Heroku envs, but Sourcetree and git console are showing the old remote name, and I can't get rid of it:
> git branch -avv
* develop [origin/develop] Merge branch 'dummy-fix' into develop
dummy-fix changed full vs first_name
master [origin/master] Merge branch 'develop'
staging [staging/master] Merge branch 'develop' into staging
remotes/heroku/master Merge branch 'develop'
remotes/origin/develop Merge branch 'dummy-fix' into develop
remotes/origin/master Merge branch 'develop'
remotes/production/master Merge branch 'develop'
remotes/staging/master Merge branch 'develop' into staging
The remote remotes/heroku/master
shouln't exist, but when I do:
> git remote rm heroku
error: Could not remove config section 'remote.heroku'
This is my .git/config
(clearly not the real URLs):
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://[email protected]
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "develop"]
remote = origin
merge = refs/heads/develop
[remote "staging"]
url = https://git.heroku.com/my-app-name-in-staging.git
fetch = +refs/heads/*:refs/remotes/staging/*
[remote "production"]
url = https://git.heroku.com/my-app-name-in-production.git
fetch = +refs/heads/*:refs/remotes/production/*
[heroku]
remote = staging
[push]
default = tracking
[branch "staging"]
remote = staging
merge = refs/heads/master
Upvotes: 0
Views: 361
Reputation: 1244
I kept digging, seems to be that .git
folder has more references to remotes that just in the config
file. Found 3 spots where I got rid manually of the folder heroku
, or the ref in config file, and that seems to fix it. Now I don't see the ghost remote neither in terminal nor Sourcetree.
Upvotes: 2