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
Running the above 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:
12
+
Running the command above adds a section to your repository's `.git/config` file, specifying the name of the remote (`origin`), the URL of the remote repository, and the _refspec_ to be used for fetching:
13
13
14
14
[source,ini]
15
15
----
@@ -18,11 +18,11 @@ Running the above adds a section to your `.git/config` file, specifying the name
18
18
fetch = +refs/heads/*:refs/remotes/origin/*
19
19
----
20
20
21
-
The format of the refspec isan 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.
21
+
The format of the refspec is, first, 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 tracked locally.
22
22
The `+` tells Git to update the reference even if it isn't a fast-forward.
23
23
24
24
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
25
+
So, if there is a `master` branch on the server, you can access the log of that branch locally via any of the following:
They're all equivalent, because Git expands each of them to `refs/remotes/origin/master`.
35
35
36
-
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
36
+
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 refer to that branch only:
In this case, the `master` branch pull was rejected because it wasn't a fast-forward reference.
64
+
In this case, the `master` branch pull was rejected because it wasn't listed as a fast-forward reference.
65
65
You can override that by specifying the `+` in front of the refspec.
66
66
67
67
You can also specify multiple refspecs for fetching in your configuration file.
68
-
If you want to always fetch the `master` and `experiment` branches, add two lines:
68
+
If you want to always fetch the `master` and `experiment` branches from the `origin` remote, add two lines:
69
69
70
70
[source,ini]
71
71
----
@@ -130,3 +130,10 @@ $ git push origin :topic
130
130
----
131
131
132
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.
133
+
134
+
Or you can use the newer syntax (available since Git v1.7.0):
0 commit comments