You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It adds a section to your `.git/config` file, specifying the name of the remote (`origin`), the URL of the remote repository, and the refspec for fetching:
@@ -18,11 +18,11 @@ It adds a section to your `.git/config` file, specifying the name of the remote
18
18
fetch = +refs/heads/*:refs/remotes/origin/*
19
19
----
20
20
21
-
The format of the refspec is an optional `+`, followed by `<src>:<dst>`, where `<src>` is the pattern for references on the remote side and `<dst>` is where those references will be written locally.
22
-
The `+` tells Git to update the reference even if it isn't a fast-forward.
In the default case that is automatically written by a `git remote add` command, Git fetches all the references under `refs/heads/` on the server and writes them to `refs/remotes/origin/` locally.
25
-
So, if there is a `master` branch on the server, you can access the log of that branch locally via
If you want Git instead to pull down only the `master` branch each time, and not every other branch on the remote server, you can change the fetch line to
You can't use partial globs in the pattern, so this would be invalid:
78
+
我们不能在模式中使用部分通配符,所以像下面这样的引用规格是不合法的:
79
79
80
80
[source]
81
81
----
82
82
fetch = +refs/heads/qa*:refs/remotes/origin/qa*
83
83
----
84
84
85
-
However, you can use namespaces (or directories) to accomplish something like that.
86
-
If you have a QA team that pushes a series of branches, and you want to get the master branch and any of the QA team's branches but nothing else, you can use a config section like this:
@@ -93,22 +93,22 @@ If you have a QA team that pushes a series of branches, and you want to get the
93
93
fetch = +refs/heads/qa/*:refs/remotes/origin/qa/*
94
94
----
95
95
96
-
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.
You can also use the refspec to delete references from the remote server by running something like this:
125
+
你还可以借助类似下面的命令通过引用规格从远程服务器上删除引用:
126
126
127
127
[source,console]
128
128
----
129
129
$ git push origin :topic
130
130
----
131
131
132
-
Because the refspec is `<src>:<dst>`, by leaving off the `<src>` part, this basically says to make the topic branch on the remote nothing, which deletes it.
0 commit comments