diff --git a/book/10-git-internals/sections/refspec.asc b/book/10-git-internals/sections/refspec.asc index f8157ce56..dd880e999 100644 --- a/book/10-git-internals/sections/refspec.asc +++ b/book/10-git-internals/sections/refspec.asc @@ -64,6 +64,9 @@ From git@github.com:schacon/simplegit In this case, the `master` branch pull was rejected because it wasn't listed as a fast-forward reference. You can override that by specifying the `+` in front of the refspec. +[[_segmenting_refspecs]] +==== Segmenting Refspecs + You can also specify multiple refspecs for fetching in your configuration file. If you want to always fetch the `master` and `experiment` branches from the `origin` remote, add two lines: @@ -75,7 +78,7 @@ If you want to always fetch the `master` and `experiment` branches from the `ori fetch = +refs/heads/experiment:refs/remotes/origin/experiment ---- -Since Git 2.6.0 you can use partial globs in the pattern to match multiple branches, so this works: +Since Git 2.6.0, you can use partial globs in the pattern to match multiple branches, so this works: [source,ini] ---- @@ -93,7 +96,19 @@ If you have a QA team that pushes a series of branches, and you want to get the fetch = +refs/heads/qa/*:refs/remotes/origin/qa/* ---- -If you have a complex workflow process that has a QA team pushing branches, developers pushing branches, and integration teams pushing and collaborating on remote branches, you can namespace them easily this way. +Since Git 2.29.0, you can also explicitly exclude patterns. +Negative refspecs start with a `^` and do not include the remote. +To get all the branches unless they start with an underscore, you can use config like this: + +[source,ini] +---- +[remote "origin"] + url = https://github.com/schacon/simplegit-progit + fetch = +refs/heads/*:refs/remotes/origin/* + fetch = ^refs/heads/_* +---- + +If you have a complex workflow process that has a QA team pushing branches, developers pushing branches, and integration teams pushing and collaborating on remote branches, you can manage them with patterns like these. [[_pushing_refspecs]] ==== Pushing Refspecs