Skip to content

Commit 7a332b2

Browse files
committed
update output of several commands to newer versions
1 parent 2c27ba0 commit 7a332b2

File tree

1 file changed

+70
-54
lines changed

1 file changed

+70
-54
lines changed

book/02-git-basics/1-git-basics.asc

Lines changed: 70 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ In <<limit_options>> we’ll list these and a few other common options for your
874874
| `--author` | Only show commits in which the author entry matches the specified string.
875875
| `--committer` | Only show commits in which the committer entry matches the specified string.
876876
| `--grep` | Only show commits with a commit message containing the string
877-
| `-S ` | Only show commits adding or removing code matching the string
877+
| `-S` | Only show commits adding or removing code matching the string
878878
|================================
879879

880880
For example, if you want to see which commits modifying test files in the Git source code history were committed by Junio Hamano and were not merges in the month of October 2008, you can run something like this:
@@ -971,6 +971,13 @@ Changes not staged for commit:
971971
The command is a bit strange, but it works.
972972
The `benchmarks.rb` file is modified but once again unstaged.
973973

974+
[NOTE]
975+
=====
976+
While `git reset` _can_ be a dangerous command if you call it with `--hard`, in this instance the file in your working directory is not touched. Calling `git reset` without an option is not dangerous - it only touches your staging area.
977+
=====
978+
979+
For now this magic invocation is all you need to know about the `git reset` command. We'll go into much more detail about what `reset` does and how to master it to do really interesting things in <<_git_tools_reset>>.
980+
974981
==== Unmodifying a Modified File
975982

976983
What if you realize that you don’t want to keep your changes to the `benchmarks.rb` file?
@@ -1003,26 +1010,27 @@ Changes to be committed:
10031010
----
10041011

10051012
You can see that the changes have been reverted.
1006-
You should also realize that this is a dangerous command: any changes you made to that file are gone – you just copied another file over it.
1013+
1014+
[IMPORTANT]
1015+
=====
1016+
It's important to understand that `git checkout -- [file]` is a dangerous command. Any changes you made to that file are gone – you just copied another file over it.
10071017
Don’t ever use this command unless you absolutely know that you don’t want the file.
1008-
If you just need to get it out of the way, we’ll go over stashing and branching in the next chapter; these are generally better ways to go.
1018+
=====
1019+
1020+
If you would like to keep the changes you've made to that file but still need to get it out of the way for now, we’ll go over stashing and branching in the next chapter; these are generally better ways to go.
10091021

1010-
Remember, anything that is committed in Git can almost always be recovered.
1022+
Remember, anything that is __committed__ in Git can almost always be recovered.
10111023
Even commits that were on branches that were deleted or commits that were overwritten with an `--amend` commit can be recovered (see <<data_recovery>> for data recovery).
10121024
However, anything you lose that was never committed is likely never to be seen again.
10131025

1014-
==== Undoing All Changes
1015-
1016-
**TODO**
1017-
10181026
=== Working with Remotes
10191027

10201028
To be able to collaborate on any Git project, you need to know how to manage your remote repositories.
10211029
Remote repositories are versions of your project that are hosted on the Internet or network somewhere.
10221030
You can have several of them, each of which generally is either read-only or read/write for you.
10231031
Collaborating with others involves managing these remote repositories and pushing and pulling data to and from them when you need to share work.
10241032
Managing remote repositories includes knowing how to add remote repositories, remove remotes that are no longer valid, manage various remote branches and define them as being tracked or not, and more.
1025-
In this section, we’ll cover these remote-management skills.
1033+
In this section, we’ll cover some of these remote-management skills.
10261034

10271035
==== Showing Your Remotes
10281036

@@ -1044,29 +1052,36 @@ $ git remote
10441052
origin
10451053
----
10461054

1047-
You can also specify `-v`, which shows you the URL that Git has stored for the shortname to be expanded to:
1055+
You can also specify `-v`, which shows you the URLs that Git has stored for the shortname to be used when reading and writing to that remote:
10481056

10491057
[source,shell]
10501058
----
10511059
$ git remote -v
1052-
origin https://github.com/schacon/ticgit.git
1060+
origin https://github.com/schacon/ticgit (fetch)
1061+
origin https://github.com/schacon/ticgit (push)
10531062
----
10541063

10551064
If you have more than one remote, the command lists them all.
1056-
For example, my Grit repository looks something like this.
1065+
For example, a repository with multiple remotes for working with several collaborators might look something like this.
10571066

10581067
[source,shell]
10591068
----
10601069
$ cd grit
10611070
$ git remote -v
1062-
bakkdoor https://github.com/bakkdoor/grit.git
1063-
cho45 https://github.com/cho45/grit.git
1064-
defunkt https://github.com/defunkt/grit.git
1065-
koke git://github.com/koke/grit.git
1066-
origin [email protected]:mojombo/grit.git
1071+
bakkdoor https://github.com/bakkdoor/grit (fetch)
1072+
bakkdoor https://github.com/bakkdoor/grit (push)
1073+
cho45 https://github.com/cho45/grit (fetch)
1074+
cho45 https://github.com/cho45/grit (push)
1075+
defunkt https://github.com/defunkt/grit (fetch)
1076+
defunkt https://github.com/defunkt/grit (push)
1077+
koke git://github.com/koke/grit.git (fetch)
1078+
koke git://github.com/koke/grit.git (push)
1079+
origin [email protected]:mojombo/grit.git (fetch)
1080+
origin [email protected]:mojombo/grit.git (push)
10671081
----
10681082

1069-
This means we can pull contributions from any of these users pretty easily.
1083+
This means we can pull contributions from any of these users pretty easily. We may additionally have permission to push to one or more of these, though we can't tell that here.
1084+
10701085
Notice that these remotes use a variety of protocols; we’ll cover why more about this in <<_git_on_the_server>>.
10711086

10721087
==== Adding Remote Repositories
@@ -1078,12 +1093,12 @@ To add a new remote Git repository as a shortname you can reference easily, run
10781093
----
10791094
$ git remote
10801095
origin
1081-
$ git remote add pb https://github.com/paulboone/ticgit.git
1096+
$ git remote add pb https://github.com/paulboone/ticgit
10821097
$ git remote -v
1083-
origin https://github.com/schacon/ticgit.git (fetch)
1084-
origin https://github.com/schacon/ticgit.git (push)
1085-
pb https://github.com/paulboone/ticgit.git (fetch)
1086-
pb https://github.com/paulboone/ticgit.git (push)
1098+
origin https://github.com/schacon/ticgit (fetch)
1099+
origin https://github.com/schacon/ticgit (push)
1100+
pb https://github.com/paulboone/ticgit (fetch)
1101+
pb https://github.com/paulboone/ticgit (push)
10871102
----
10881103

10891104
Now you can use the string `pb` on the command line in lieu of the whole URL.
@@ -1100,7 +1115,10 @@ From https://github.com/paulboone/ticgit
11001115
* [new branch] master -> pb/master
11011116
* [new branch] ticgit -> pb/ticgit
11021117
----
1103-
Paul’s master branch is accessible locally as `pb/master` – you can merge it into one of your branches, or you can check out a local branch at that point if you want to inspect it.
1118+
1119+
Paul’s master branch is now accessible locally as `pb/master` – you can merge it into one of your branches, or you can check out a local branch at that point if you want to inspect it.
1120+
(We’ll go over what branches are and how to use them in much more detail in <<_git_branching>>.)
1121+
11041122

11051123
==== Fetching and Pulling from Your Remotes
11061124

@@ -1113,11 +1131,10 @@ $ git fetch [remote-name]
11131131

11141132
The command goes out to that remote project and pulls down all the data from that remote project that you don’t have yet.
11151133
After you do this, you should have references to all the branches from that remote, which you can merge in or inspect at any time.
1116-
(We’ll go over what branches are and how to use them in much more detail in <<_git_branching>>.)
11171134

11181135
If you clone a repository, the command automatically adds that remote repository under the name origin.
11191136
So, `git fetch origin` fetches any new work that has been pushed to that server since you cloned (or last fetched from) it.
1120-
It’s important to note that the fetch command pulls the data to your local repository – it doesn’t automatically merge it with any of your work or modify what you’re currently working on.
1137+
It’s important to note that the `git fetch` command pulls the data to your local repository – it doesn’t automatically merge it with any of your work or modify what you’re currently working on.
11211138
You have to merge it manually into your work when you’re ready.
11221139

11231140
If you have a branch set up to track a remote branch (see the next section and <<_git_branching>> for more information), you can use the `git pull` command to automatically fetch and then merge a remote branch into your current branch.
@@ -1128,7 +1145,7 @@ Running `git pull` generally fetches data from the server you originally cloned
11281145

11291146
When you have your project at a point that you want to share, you have to push it upstream.
11301147
The command for this is simple: `git push [remote-name] [branch-name]`.
1131-
If you want to push your master branch to your `origin` server (again, cloning generally sets up both of those names for you automatically), then you can run this to push your work back up to the server:
1148+
If you want to push your master branch to your `origin` server (again, cloning generally sets up both of those names for you automatically), then you can run this to push any commits you've done back up to the server:
11321149

11331150
[source,shell]
11341151
----
@@ -1149,12 +1166,12 @@ If you run this command with a particular shortname, such as `origin`, you get s
11491166
----
11501167
$ git remote show origin
11511168
* remote origin
1152-
Fetch URL: https://github.com/schacon/ticgit.git
1153-
Push URL: https://github.com/schacon/ticgit.git
1169+
Fetch URL: https://github.com/schacon/ticgit
1170+
Push URL: https://github.com/schacon/ticgit
11541171
HEAD branch: master
11551172
Remote branches:
1156-
master tracked
1157-
ticgit tracked
1173+
master tracked
1174+
dev-branch tracked
11581175
Local branch configured for 'git pull':
11591176
master merges with remote master
11601177
Local ref configured for 'git push':
@@ -1172,33 +1189,32 @@ When you’re using Git more heavily, however, you may see much more information
11721189
----
11731190
$ git remote show origin
11741191
* remote origin
1175-
URL: [email protected]:defunkt/github.git
1176-
Remote branch merged with 'git pull' while on branch issues
1177-
issues
1178-
Remote branch merged with 'git pull' while on branch master
1179-
master
1180-
New remote branches (next fetch will store in remotes/origin)
1181-
caching
1182-
Stale tracking branches (use 'git remote prune')
1183-
libwalker
1184-
walker2
1185-
Tracked remote branches
1186-
acl
1187-
apiv2
1188-
dashboard2
1189-
issues
1190-
master
1191-
postgres
1192-
Local branch pushed with 'git push'
1193-
master:master
1194-
----
1195-
1196-
This command shows which branch is automatically pushed when you run `git push` on certain branches.
1192+
URL: https://github.com/my-org/complex-project
1193+
Fetch URL: https://github.com/my-org/complex-project
1194+
Push URL: https://github.com/my-org/complex-project
1195+
HEAD branch: master
1196+
Remote branches:
1197+
master tracked
1198+
dev-branch tracked
1199+
markdown-strip tracked
1200+
issue-43 new (next fetch will store in remotes/origin)
1201+
issue-45 new (next fetch will store in remotes/origin)
1202+
refs/remotes/origin/issue-11 stale (use 'git remote prune' to remove)
1203+
Local branches configured for 'git pull':
1204+
dev-branch merges with remote dev-branch
1205+
master merges with remote master
1206+
Local refs configured for 'git push':
1207+
dev-branch pushes to dev-branch (up to date)
1208+
markdown-strip pushes to markdown-strip (up to date)
1209+
master pushes to master (up to date)
1210+
----
1211+
1212+
This command shows which branch is automatically pushed to when you run `git push` while on certain branches.
11971213
It also shows you which remote branches on the server you don’t yet have, which remote branches you have that have been removed from the server, and multiple branches that are automatically merged when you run `git pull`.
11981214

11991215
==== Removing and Renaming Remotes
12001216

1201-
If you want to rename a reference, in newer versions of Git you can run `git remote rename` to change a remote’s shortname.
1217+
If you want to rename a reference you can run `git remote rename` to change a remote’s shortname.
12021218
For instance, if you want to rename `pb` to `paul`, you can do so with `git remote rename`:
12031219

12041220
[source,shell]

0 commit comments

Comments
 (0)