If you mean not having a local branch track changes on a remote branch:
You do not have to have your branches track a remote branch. It is a convenience that has a few benefits that you won't have; such as git status
stating that your branch is x commits ahead of origin's.
Not setting up a tracking branch does not prevent you from using remotes. Remotes can still be used in all commands instead of typing the URL.
To see what branches are tracked use git branch -avv
. Any branches that are tracking a remote branch will list the remote branch to the left of the commit hash.
I don't know a way to remove the tracking from a branch other than to delete it and recreate without tracking.
If you mean the local copy of the remote branch (as seen by git branch -r
):
You can delete these with git branch -dr <remote/branch>
-- but it will come back next time you pull or fetch it. They are required for git fetch ...
to work, and git pull ...
uses git fetch ...
. They would have to be manually deleted each time -- or scripted.
However, they do not add any real clutter or overhead to the repository. The remote tracking branch is, on disk, just a file with a commit hash in it. The commits are saved elsewhere and presumably, since you wanted to fetch them, they have been merged or rebased into one or more local branches.
This information can be fetch using a URL instead of a remote. This does not create a record of what was fetched anywhere but the FETCH_HEAD file. Since this file is overridden with each fetch, the commit data will be lost if not merged or rebased into a local branch before another fetch is performed. The remote tracking branch is there to keep the fetched data from being garbage collected.