Currently, when I pull, I get changes from all the branches:
$ git pull
remote: ...
Unpacking objects: ...
From ssh://github.com/...
a69d94d..a2019da master -> origin/master
b684d4a..b8819dc develop -> origin/develop
+ 263c644..f1c1894 gh-pages -> origin/gh-pages (forced update)
Updating a69d94d..a2019da
I like this behavior, but I don't need to get content from the gh-pages
branch as that only contains generated content. How do I configure Git to fetch from all branches except some (gh-pages
). I'd also like to avoid ever seeing gh-pages
in my list of local branches.
The idea is to use the git-clone to clone the repository. This will automatically fetch all the branches and tags in the cloned repository. To check out the specific branch, you can use the git-checkout command to create a local tracking branch.
git fetch --prune is the best utility for cleaning outdated branches. It will connect to a shared remote repository remote and fetch all remote branch refs. It will then delete remote refs that are no longer in use on the remote repository.
It will only change your current local branch in the merge part, but the fetch part will update all of the other remote branches if they had changes since the last fetch.
You could modify your config to fetch only one branch:
[remote "origin"]
fetch = +refs/heads/master:refs/remotes/origin/master
With
git config remote.origin.fetch +refs/heads/master:refs/remotes/origin/master
If you have more than one branch, you can add several fetch directives to fetch those (except gh-pages
, the one you don't want to fetch)
See this question for an example of a multiple-branch fetch.
I understand this isn't a solution that scales well, but a fetch refspec doesn't support the normal exclusion syntax (like ^<rev>
: see "Specifying ranges").
There is a way to hide a certain refspec, introduced in git 1.8.2: commit daebaa7, "upload/receive-pack: allow hiding ref hierarchies", but that is on the remote side, not one the client side.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With