Return to Video

Reset• GitHub & Git Foundations

  • 0:00 - 0:04
    Git reset はレポジトリの履歴を
    形成できるコマンドです
  • 0:04 - 0:08
    変更を取り消したり
    コミットを修正したりするなら
  • 0:08 - 0:09
    このコマンドを使いましょう
  • 0:10 - 0:11
    ♪ (ボッサの音楽) ♪
  • 0:15 - 0:17
    Git and GitHub Foundationsによる
  • 0:17 - 0:19
    reset コマンドの
    エピソードにようこそ
  • 0:19 - 0:22
    このコマンドには多くの機能があり
    様々なモードがあります
  • 0:22 - 0:25
    ここでご紹介するのは3つのモードです
  • 0:25 - 0:28
    これらは
    soft ; mixedまたは標準設定; そしてhard です
  • 0:29 - 0:31
    ♪ (音楽) ♪
  • 0:31 - 0:33
    これらの名称は機能を説明しています
  • 0:33 - 0:36
    まずは標準設定のmixedから
    始めましょう
  • 0:36 - 0:40
    これは履歴だけでなく
    作業中のディレクトリも変更します
  • 0:40 - 0:42
    だからミックス―
    両方だというわけです
  • 0:42 - 0:44
    softは1つか複数のコミットの変更を
  • 0:44 - 0:47
    ステージングエリアに戻します
  • 0:47 - 0:50
    それをもとに新しいコミットの作成を
    継続できます
  • 0:50 - 0:53
    一方Hard は破壊的な作業です
  • 0:53 - 0:56
    つまり保存しておきたくないものを
    消すための作業です
  • 0:56 - 0:59
    これら3つを念頭に置いて
  • 0:59 - 1:01
    まずはmixed から見ていきましょう
  • 1:03 - 1:05
    Mixed はGitを使い始めたユーザーに
  • 1:05 - 1:07
    度々推奨されるもので
  • 1:07 - 1:09
    なぜならstatus コマンドの中に
    表示されるからです
  • 1:09 - 1:11
    ステージングエリアに変更があり
  • 1:11 - 1:14
    git status を見ると
    git reset HEADがあります
  • 1:14 - 1:17
    これによってこれらの変更を
    ステージングエリアに持ち込み
  • 1:17 - 1:19
    mixed オプションで
    作業中のディレクトリに
  • 1:19 - 1:20
    戻すことができます
  • 1:21 - 1:23
    Soft というのは
    細かすぎる変更を
  • 1:23 - 1:26
    扱うときに使うものです
  • 1:26 - 1:28
    1 2 3 4 5つのコミットが
  • 1:28 - 1:31
    すべて1つのトランザクションで
    あることに気付いたので
  • 1:31 - 1:32
    すべてまとめることにします
  • 1:32 - 1:37
    git reset -- soft HEAD~5 を使って
  • 1:37 - 1:38
    最近の5つのコミットをまとめましょう
  • 1:39 - 1:41
    soft を使ったこのコマンドで
  • 1:41 - 1:43
    5つのコミットをすべて―
  • 1:43 - 1:46
    1つのコミットとして
    ステージングエリアにまとめられます
  • 1:47 - 1:49
    履歴の修正にはとても役立ちますが
  • 1:49 - 1:51
    履歴の修正には価値を付与しないコミットを
  • 1:51 - 1:54
    破棄するという極端な場合もあります
  • 1:54 - 1:58
    送信・発信したり 他の人と共有したくない場合です
  • 1:58 - 1:59
    ここでhard が役に立ちます
  • 1:59 - 2:02
    一部の作業を完全に削除したい場合
  • 2:02 - 2:05
    変更を試みたけれど
    うまくいかなかった場合などは
  • 2:05 - 2:08
    git reset -- hard を使って
    完全にこれらのコミットを削除できます
  • 2:09 - 2:11
    ではどうしてコミットを
    作るのかと尋ねるかもしれません
  • 2:11 - 2:14
    reflog コマンドは
    今後のエピソードでご紹介しますが
  • 2:14 - 2:17
    reflog コマンドはとてもいい
    セーフティーネットを提供するので
  • 2:17 - 2:20
    コミットでチェックポイントを
    作る気にさせるでしょう
  • 2:20 - 2:22
    hard が使えることを
    知っていることで
  • 2:22 - 2:25
    履歴をいつでも整理できますね
  • 2:25 - 2:27
    ♪ (音楽) ♪
  • 2:28 - 2:32
    reset と一緒に語られることの多い
    親戚のようなコマンドがあります
  • 2:32 - 2:34
    checkout というコマンドです
  • 2:34 - 2:38
    checkout コマンドはreset とは
    少し精度が異なり
  • 2:38 - 2:41
    たいていレポジトリの履歴全体を
    操作するものです
  • 2:42 - 2:45
    Checkout はディレクトリや
    ファイルレベルの操作に特化しています
  • 2:46 - 2:49
    コミット全体を取り消したり
    変更するのではなく
  • 2:49 - 2:53
    履歴でコミットの
    特定のファイルに戻ることができ
  • 2:53 - 2:57
    そのファイルとバージョンを
    現在作業中のディレクトリに戻します
  • 2:58 - 3:01
    Gitレポジトリの履歴が目指すところは
    明瞭なコミュニケーションです
  • 3:01 - 3:06
    ですからgit reset hard でも
    reset soft でも reset mixed でも
  • 3:06 - 3:08
    より正確なcheckout コマンドでも
  • 3:08 - 3:13
    あなたの変更の明確な意図が
    同僚に伝わるように使ってください
  • 3:13 - 3:16
    Git reset は新しいGitユーザーには
    少し使うのが怖いツールのように
  • 3:16 - 3:17
    思えるかもしれません
  • 3:17 - 3:20
    でも 美しいレポジトリの履歴を
    作るために
  • 3:20 - 3:22
    とても役立つツールにもなります
  • 3:24 - 3:28
    Git and GitHub Foundationsのreset 編を
    ご覧いただきありがとうございます
  • 3:28 - 3:32
    いつも通り 横にあるチャンネルを
    購読するのをお忘れなく
  • 3:32 - 3:34
    質問やコメントは下にどうぞ
  • 3:34 - 3:36
    GitやGitHubに関する
    ためになるトピックも
  • 3:36 - 3:39
    下でチェックしてくださいね
  • 3:39 - 3:42
    ♪ (音楽) ♪
    (音声が静かになる)
Title:
Reset• GitHub & Git Foundations
Description:

Git reset is the command that allows you to discard or revise commit history within your repository. Whether you're undoing some changes or re-crafting your commits in a new way, git reset is the appropriate command. We'll also take a look at several of reset's command line options and examine how git checkout performs similar functions.

As always, leave us a comment below if you have any questions, and don't forget to subscribe: http://bit.ly/githubguides.

Thanks!

Connect with us.
Facebook: http://fb.com/github
Twitter: http://twitter.com/github and http://twitter.com/githubtraining
Google+: http://google.com/+githubguides
LinkedIn: http://linkedin.com/company/github

About GitHub
GitHub is the best place to share code with friends, co-workers, classmates, and complete strangers. Millions of people use GitHub to build amazing things together. For more info, go to http://github.comGit reset is the command that allows you to discard or revise commit history within your repository. Whether you're undoing some changes or re-crafting your commits in a new way, git reset is the appropriate command. We'll also take a look at several of reset's command line options and examine how git checkout performs similar functions.

As always, leave us a comment below if you have any questions, and don't forget to subscribe: http://bit.ly/githubguides.

Thanks!

Connect with us.
Facebook: http://fb.com/github
Twitter: http://twitter.com/github and http://twitter.com/githubtraining
Google+: http://google.com/+githubguides
LinkedIn: http://linkedin.com/company/github

About GitHub
GitHub is the best place to share code with friends, co-workers, classmates, and complete strangers. Millions of people use GitHub to build amazing things together. For more info, go to http://github.com

more » « less
Video Language:
English
Team:
GitHub
Project:
Git and GitHub Foundations
Duration:
03:48
There has been no activity on this language so far.

Japanese subtitles

Revisions Compare revisions