From the documentation, https://git-scm.com/docs/git-remote#Documentation/git-remote.txt-emset-branchesem, it is not clear to me what it actually does.
From the documentation, https://git-scm.com/docs/git-remote#Documentation/git-remote.txt-emset-branchesem, it is not clear to me what it actually does.
That was introduced with Git v1.7.2-rc0 in May 2010, commit 3d8b694 with the comment:
Add git remote set-branches
Add ‘
git remote set-branches’ for changing the list of tracked refs for a remote repository with one "porcelain-level" command.
This complements the longstanding ‘git remote add --track’ option.The interface is based on the ‘git remote set-url’ subcommand.
git remote set-branches base --add C git remote set-branches base A B D git remote set-branches base --delete D; # not implemented
So instead of the default glob refspec for the remote to track all branches under the refs/remotes/<name>/ namespace, a refspec is updated to track only <branch>
git remote add -t main o2 https://github.com/git/git
Would give:
[remote "o2"]
url = https://github.com/git/git
fetch = +refs/heads/main:refs/remotes/o2/main
Instead of:
fetch = +refs/heads/*:refs/remotes/origin/*
Adding a branch would be:
git remote set-branches o2 --add master
[remote "o2"]
url = https://github.com/git/git
fetch = +refs/heads/main:refs/remotes/o2/main
fetch = +refs/heads/main:refs/remotes/o2/master