Skip to content

Commit 62e8dfa

Browse files
committed
merge together changes favoring switch and restore over checkout
resolves #1524
3 parents 2ee8bf3 + 191a4f1 + 4c95573 commit 62e8dfa

7 files changed

Lines changed: 24 additions & 24 deletions

File tree

‎book/02-git-basics/sections/recording-changes.asc‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Changes to be committed:
114114
115115
Changes not staged for commit:
116116
(use "git add <file>..." to update what will be committed)
117-
(use "git checkout -- <file>..." to discard changes in working directory)
117+
(use "git restore <file>..." to discard changes in working directory)
118118
119119
modified: CONTRIBUTING.md
120120
@@ -159,7 +159,7 @@ Changes to be committed:
159159
160160
Changes not staged for commit:
161161
(use "git add <file>..." to update what will be committed)
162-
(use "git checkout -- <file>..." to discard changes in working directory)
162+
(use "git restore <file>..." to discard changes in working directory)
163163
164164
modified: CONTRIBUTING.md
165165
@@ -299,7 +299,7 @@ Changes to be committed:
299299
300300
Changes not staged for commit:
301301
(use "git add <file>..." to update what will be committed)
302-
(use "git checkout -- <file>..." to discard changes in working directory)
302+
(use "git restore <file>..." to discard changes in working directory)
303303
304304
modified: CONTRIBUTING.md
305305
----
@@ -363,7 +363,7 @@ Changes to be committed:
363363
364364
Changes not staged for commit:
365365
(use "git add <file>..." to update what will be committed)
366-
(use "git checkout -- <file>..." to discard changes in working directory)
366+
(use "git restore <file>..." to discard changes in working directory)
367367
368368
modified: CONTRIBUTING.md
369369
----
@@ -497,7 +497,7 @@ On branch master
497497
Your branch is up-to-date with 'origin/master'.
498498
Changes not staged for commit:
499499
(use "git add <file>..." to update what will be committed)
500-
(use "git checkout -- <file>..." to discard changes in working directory)
500+
(use "git restore <file>..." to discard changes in working directory)
501501
502502
modified: CONTRIBUTING.md
503503
@@ -528,7 +528,7 @@ On branch master
528528
Your branch is up-to-date with 'origin/master'.
529529
Changes not staged for commit:
530530
(use "git add/rm <file>..." to update what will be committed)
531-
(use "git checkout -- <file>..." to discard changes in working directory)
531+
(use "git restore <file>..." to discard changes in working directory)
532532
533533
deleted: PROJECTS.md
534534

‎book/02-git-basics/sections/undoing.asc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Changes to be committed:
8484
8585
Changes not staged for commit:
8686
(use "git add <file>..." to update what will be committed)
87-
(use "git checkout -- <file>..." to discard changes in working directory)
87+
(use "git restore <file>..." to discard changes in working directory)
8888
8989
modified: CONTRIBUTING.md
9090
----
@@ -112,7 +112,7 @@ In the last example output, the unstaged area looks like this:
112112
----
113113
Changes not staged for commit:
114114
(use "git add <file>..." to update what will be committed)
115-
(use "git checkout -- <file>..." to discard changes in working directory)
115+
(use "git restore <file>..." to discard changes in working directory)
116116
117117
modified: CONTRIBUTING.md
118118
----
@@ -122,7 +122,7 @@ Let's do what it says:
122122

123123
[source,console]
124124
----
125-
$ git checkout -- CONTRIBUTING.md
125+
$ git restore CONTRIBUTING.md
126126
$ git status
127127
On branch master
128128
Changes to be committed:
@@ -136,7 +136,7 @@ You can see that the changes have been reverted.
136136

137137
[IMPORTANT]
138138
=====
139-
It's important to understand that `git checkout \-- <file>` is a dangerous command.
139+
It's important to understand that `git restore <file>` is a dangerous command.
140140
Any local changes you made to that file are gone -- Git just replaced that file with the last staged or committed version.
141141
Don't ever use this command unless you absolutely know that you don't want those unsaved local changes.
142142
=====

‎book/07-git-tools/sections/advanced-merging.asc‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ Let's explore a couple of tools that you now have at your disposal to determine
357357
Perhaps it's not obvious how exactly you should fix this conflict.
358358
You need more context.
359359

360-
One helpful tool is `git checkout` with the `--conflict` option.
360+
One helpful tool is `git restore` with the `--conflict` option.
361361
This will re-checkout the file again and replace the merge conflict markers.
362362
This can be useful if you want to reset the markers and try to resolve them again.
363363

@@ -366,7 +366,7 @@ If you pass it `diff3`, Git will use a slightly different version of conflict ma
366366

367367
[source,console]
368368
----
369-
$ git checkout --conflict=diff3 hello.rb
369+
$ git restore --conflict=diff3 hello.rb
370370
----
371371

372372
Once we run that, the file will look like this instead:
@@ -395,7 +395,7 @@ If you like this format, you can set it as the default for future merge conflict
395395
$ git config --global merge.conflictstyle diff3
396396
----
397397

398-
The `git checkout` command can also take `--ours` and `--theirs` options, which can be a really fast way of just choosing either one side or the other without merging things at all.
398+
The `git restore` command can also take `--ours` and `--theirs` options, which can be a really fast way of just choosing either one side or the other without merging things at all.
399399

400400
This can be particularly useful for conflicts of binary files where you can simply choose one side, or where you only want to merge certain files in from another branch -- you can do the merge and then checkout certain files from one side or the other before committing.
401401

‎book/07-git-tools/sections/interactive-staging.asc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,5 +200,5 @@ At this point, you can exit the interactive adding script and run `git commit` t
200200

201201
You also don't need to be in interactive add mode to do the partial-file staging -- you can start the same script by using `git add -p` or `git add --patch` on the command line.
202202

203-
Furthermore, you can use patch mode for partially resetting files with the `git reset --patch` command, for checking out parts of files with the `git checkout --patch` command and for stashing parts of files with the `git stash save --patch` command.
203+
Furthermore, you can use patch mode for partially resetting files with the `git reset --patch` command, for checking out parts of files with the `git restore --patch` command and for stashing parts of files with the `git stash save --patch` command.
204204
We'll go into more details on each of these as we get to more advanced usages of these commands.

‎book/07-git-tools/sections/rerere.asc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,11 @@ index a440db6,54336ba..0000000
210210
.Automatically resolved merge conflict using previous resolution
211211
image::images/rerere3.png[Automatically resolved merge conflict using previous resolution]
212212

213-
You can also recreate the conflicted file state with `git checkout`:
213+
You can also recreate the conflicted file state with `git restore`:
214214

215215
[source,console]
216216
----
217-
$ git checkout --conflict=merge hello.rb
217+
$ git restore --conflict=merge hello.rb
218218
$ cat hello.rb
219219
#! /usr/bin/env ruby
220220

‎book/07-git-tools/sections/stashing-cleaning.asc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Changes to be committed:
3232
3333
Changes not staged for commit:
3434
(use "git add <file>..." to update what will be committed)
35-
(use "git checkout -- <file>..." to discard changes in working directory)
35+
(use "git restore <file>..." to discard changes in working directory)
3636
3737
modified: lib/simplegit.rb
3838
----
@@ -80,7 +80,7 @@ $ git stash apply
8080
On branch master
8181
Changes not staged for commit:
8282
(use "git add <file>..." to update what will be committed)
83-
(use "git checkout -- <file>..." to discard changes in working directory)
83+
(use "git restore <file>..." to discard changes in working directory)
8484
8585
modified: index.html
8686
modified: lib/simplegit.rb
@@ -109,7 +109,7 @@ Changes to be committed:
109109
110110
Changes not staged for commit:
111111
(use "git add <file>..." to update what will be committed)
112-
(use "git checkout -- <file>..." to discard changes in working directory)
112+
(use "git restore <file>..." to discard changes in working directory)
113113
114114
modified: lib/simplegit.rb
115115
----
@@ -214,7 +214,7 @@ Changes to be committed:
214214
215215
Changes not staged for commit:
216216
(use "git add <file>..." to update what will be committed)
217-
(use "git checkout -- <file>..." to discard changes in working directory)
217+
(use "git restore <file>..." to discard changes in working directory)
218218
219219
modified: lib/simplegit.rb
220220

‎book/07-git-tools/sections/submodules.asc‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ Your branch is up-to-date with 'origin/master'.
293293
294294
Changes not staged for commit:
295295
(use "git add <file>..." to update what will be committed)
296-
(use "git checkout -- <file>..." to discard changes in working directory)
296+
(use "git restore <file>..." to discard changes in working directory)
297297
298298
modified: .gitmodules
299299
modified: DbConnector (new commits)
@@ -313,7 +313,7 @@ Your branch is up-to-date with 'origin/master'.
313313
314314
Changes not staged for commit:
315315
(use "git add <file>..." to update what will be committed)
316-
(use "git checkout -- <file>..." to discard changes in working directory)
316+
(use "git restore <file>..." to discard changes in working directory)
317317
318318
modified: .gitmodules
319319
modified: DbConnector (new commits)
@@ -400,7 +400,7 @@ $ git status
400400
Your branch is up-to-date with 'origin/master'.
401401
Changes not staged for commit:
402402
(use "git add <file>..." to update what will be committed)
403-
(use "git checkout -- <file>..." to discard changes in working directory)
403+
(use "git restore <file>..." to discard changes in working directory)
404404
405405
modified: DbConnector (new commits)
406406
@@ -1032,7 +1032,7 @@ Switched to branch 'master'
10321032
----
10331033

10341034
Then, when you switch back, you get an empty `CryptoLibrary` directory for some reason and `git submodule update` may not fix it either.
1035-
You may need to go into your submodule directory and run a `git checkout .` to get all your files back.
1035+
You may need to go into your submodule directory and run a `git restore .` to get all your files back.
10361036
You could run this in a `submodule foreach` script to run it for multiple submodules.
10371037

10381038
It's important to note that submodules these days keep all their Git data in the top project's `.git` directory, so unlike much older versions of Git, destroying a submodule directory won't lose any commits or branches that you had.

0 commit comments

Comments
 (0)