Reputation: 3592
The contents of config file in my .git directory are like this:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
worktree = ../../src/PKGNAME
[remote "origin"]
url = ssh://git.COMPANYNAME.com:port/pkg/PKGNAME
fetch = +refs/heads/*:refs/remotes/origin/*
[remote "backup"]
url = ssh://git.COMPANYNAME.com:port/pkg/PKGNAME/backup/username
fetch = +refs/heads/*:refs/remotes/backup/*
push = +refs/heads/*:refs/heads/*
[remote "share"]
url = ssh://git.COMPANYNAME.com:port/pkg/PKGNAME/share/username
fetch = +refs/heads/*:refs/remotes/share/*
push = +refs/heads/*:refs/heads/*
[branch "integTests"]
remote = origin
merge = refs/heads/mainline
rebase = true
[branch "clean"]
remote = origin
merge = refs/heads/mainline
rebase = true
I ran git push and it shared all the local branches, even those which were not listed in this config file. The output was this:
$ git push share
Counting objects: 109, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (45/45), done.
Writing objects: 100% (100/100), 6.70 KiB | 0 bytes/s, done.
Total 100 (delta 34), reused 0 (delta 0)
To ssh://git.COMPANYNAME.com:port/pkg/PKGNAME/share/username
* [new branch] clean -> clean
* [new branch] fresh -> fresh
* [new branch] integTests -> integTests
* [new branch] mainline -> mainline
I want to share only my mainline branch. How do I unshare the rest?
Upvotes: 1
Views: 1156
Reputation: 62399
In addition to the answer by @janos that shows how to delete the erroneously pushed branches on the remote, you want to change your push
specification for that remote so it looks like this:
[remote "share"]
url = ssh://git.COMPANYNAME.com:port/pkg/PKGNAME/share/username
fetch = +refs/heads/*:refs/remotes/share/*
push = +refs/heads/mainline:refs/heads/mainline
That way, the only branch git push
will concern itself with when talking to the share
remote is your mainline
branch...
Edit: Incorporating advice from @janos on deleting erroneously pushed branches on the remote:
You have to delete the others one by one:
git push share :clean
git push share :fresh
git push share :integTests
Upvotes: 1