Skip to content

Commit 191a4f1

Browse files
committed
replace git checkout with git restore for restoring file contents
from tree-ish into working copy and/or staging area
1 parent a013e32 commit 191a4f1

5 files changed

Lines changed: 9 additions & 9 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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/submodules.asc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ Switched to branch 'master'
10311031
----
10321032

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

10371037
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)