Skip to content

Commit e16e0d4

Browse files
authored
Merge pull request #921 from rpjday/refspec
Minor tweaks and rewording to "The Refspec" section.
2 parents 952b6ac + 01888e5 commit e16e0d4

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

book/10-git-internals/sections/refspec.asc

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
=== The Refspec
33

44
Throughout this book, we've used simple mappings from remote branches to local references, but they can be more complex.
5-
Suppose you add a remote like this:
5+
Suppose you were following along with the last couple sections and had created a small local Git repository, and now wanted to add a _remote_ to it:
66

77
[source,console]
88
----
99
$ git remote add origin https://github.com/schacon/simplegit-progit
1010
----
1111

12-
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:
1313

1414
[source,ini]
1515
----
@@ -18,11 +18,11 @@ Running the above adds a section to your `.git/config` file, specifying the name
1818
fetch = +refs/heads/*:refs/remotes/origin/*
1919
----
2020

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.
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.
2222
The `+` tells Git to update the reference even if it isn't a fast-forward.
2323

2424
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:
2626

2727
[source,console]
2828
----
@@ -33,16 +33,16 @@ $ git log refs/remotes/origin/master
3333

3434
They're all equivalent, because Git expands each of them to `refs/remotes/origin/master`.
3535

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:
3737

3838
[source]
3939
----
4040
fetch = +refs/heads/master:refs/remotes/origin/master
4141
----
4242

4343
This is just the default refspec for `git fetch` for that remote.
44-
If you want to do something one time, you can specify the refspec on the command line, too.
45-
To pull the `master` branch on the remote down to `origin/mymaster` locally, you can run
44+
If you want to do a one-time only fetch, you can specify the specific refspec on the command line, too.
45+
To pull the `master` branch on the remote down to `origin/mymaster` locally, you can run:
4646

4747
[source,console]
4848
----
@@ -61,11 +61,11 @@ From [email protected]:schacon/simplegit
6161
* [new branch] topic -> origin/topic
6262
----
6363

64-
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.
6565
You can override that by specifying the `+` in front of the refspec.
6666

6767
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:
6969

7070
[source,ini]
7171
----
@@ -130,3 +130,10 @@ $ git push origin :topic
130130
----
131131

132132
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):
135+
136+
[source,console]
137+
----
138+
$ git push origin --delete topic
139+
----

0 commit comments

Comments
 (0)