字幕表 動画を再生する
Do you have trouble committing? In this episode
コミットでお困りですか?
of GitHub Foundations, we're gonna look at three different ways
今回のGitHub 基礎では Git でのコミットを
to make a commit in Git.
3つの方法でご紹介します
[GitHub & Git Foundations]
[GitHub と Git の基礎]
♪(easy listening music)♪
♪(イージーリスニングの音楽)♪
[Commit]
[コミット]
Hi, I'm Tim Berglund. The whole point of using
ティム・バーグランドです ソース管理システムを
a source control system is to keep track of changes. In Git,
使う目的は変更を 記録することです
these are called commits. Here, we're gonna look at three
Git ではこれをコミットと呼びます 今回は3つの方法を通して
different ways to make a commit.
コミットを見てみましょう
[Commit: Command Line]
[コミット: コマンドライン]
We'll start at our local computer, down at the command line.
ローカルのマシンで始めます 下のコマンドラインに行きましょう
Now suppose you've already got a project that you've started on.
すでに着手したプロジェクトが あるとします
It doesn't matter what the language or platform is, just as long as
言語やプラットフォームは問いません
it's text files arranged in directories. Now you're gonna
ディレクトリにテキストファイルが あればいいんです
use a text editor to make a change to one of those files,
テキストエディタで 1つのファイルに1箇所編集します
or maybe you'll change a few at once. The "git status" command
1度に複数のファイルを 編集しても大丈夫です
is gonna tell you about what files might need to be committed.
git status コマンドでどのファイルを コミットしたらいいか分かります
It's gonna tell you about files that have changed, or maybe
変更のあったファイル または最新のコミットのあとに
new files that you've added since the last commit.
新規追加したファイルなどを 教えてくれます
To take those changes and get them ready to be committed,
変更したファイルを コミットするには
use the "git add" command. This puts them in a special
git add コマンドを使います このコマンドはファイルを
holding tank called the staging area. You can see that they've
ステージングエリアと呼ばれる 特別な領域に移します
moved to the staging area by using the "status" command
もう一度 status コマンドを使うと ステージングエリアに移動したのが
again, and notice that the output looks different.
分かります 出力が違うのが見えますね
Every time you commit a change, it has to go through
変更をコミットするときに 必ず通過するのが
the staging area. This is a key part of Git's architecture.
ステージングエリアです これは Git の設計の要です
It can seem strange at first, but the more you use Git,
最初は変に思うかもしれませんが Git を使うにつれて
the more sense it will make. To complete the process,
納得いくようになるでしょう このプロセスを完了するには
use the "git commit" command. Be sure to include a nice
git commit コマンドを使います 他の人にも分かるように
descriptive message so that other people can understand
このコミットについて分かりやすい 説明文を入れてあげてください
what this commit is all about. If you don't include a message,
そのような説明文の メッセージがないと
Git will actually open a text editor and make you enter one.
Git はテキストエディタを開いて 入力を促します
It's not gonna let you get away with making a commit
メッセージなしでは コミットはできません
without describing it. You should notice this: if you were to
同じファイルを再度編集すると 気が付くと思いますが
edit that same file a second time, you'd actually use the "git add"
git add コマンドを使ってから
command again before committing it, and then,
コミットしようと思うでしょう そしてファイルステージでは
with the file stage, you'd use the "git commit" command again
git commit コマンドをまた使って
to take another snapshot of your changes. In a real project,
変更のスナップショットを 取ろうとします
a lot of the time, you'll change many files at once.
実際のプロジェクトではよく 複数のファイルを1度に変更しますよね
The staging area gives you the flexibility to decide
ステージングエリアは 変更に対して柔軟に対応して
what changes become a part of what commit. And as you
どのコミットでどの変更を反映させるか 決定することができます
get more and more comfortable using Git, you're gonna
Git に慣れ親しんでくると
start to pay attention to the way you craft commits.
コミットに対して細心の注意を 払うようになるでしょう
Each one should be a coherent story that makes sense
それぞれのコミットは 他の人が履歴を見ても分かるように
to another person looking at your history. It's not just
一貫性のある ストーリーが必要です
a jumble of changes that you happen to have made since
最新のコミットのあとに たまたま変更したものの
the last time you've committed. Don't worry if this
寄せ集めではありません
doesn't make sense yet. It'll start to make a lot more sense
まだ良く分からなくても大丈夫です Git をもっと使って
as use Git more and more together
他の人とも一緒に使っていくと 段々と分かるようになります
with other people.
[コミット: GitHub.com]
[Commit: GitHub.com]
GitHub.com ですでに プロジェクトがあるとします
Now, what if you've already got a project up on GitHub.com?
そこでコミットもできます
Well, you can make commits there too. Click on the file
編集するファイルをクリックして
you want to edit, and then click the "edit" button
ブラウザで"edit" ボタンをクリックすると
in the browser. You'll get a simple text editor where
簡単なテキストエディタが出てきて ファイルを編集できます
you can make changes to your file. When you submit
変更を保存すると GitHub は そのファイルの変更箇所のみを
those changes, GitHub will create a new commit containing
含むコミットを作成します
just the changes to that file. Doing it this way, you don't have
このようにすると何をコミットするか 1つずつは管理できませんが
quite as much control over what goes into each commit,
コマンドラインに 慣れてない人でも
but it's a lot easier to do for people who aren't comfortable
簡単にコミットができて 簡単にテキストファイルを
using the command line, and for making really simple
編集することができます
changes to text files.
[コミット: GitHub for Mac / Windows]
[Commit: GitHub for Mac / Windows]
最後に ローカルマシンに戻って コードをコミットするには
Finally, maybe back on your computer, you can commit code
GitHub デスクトップからもできます
using GitHub for Desktop. This still makes a commit locally
これはまだローカルでのコミットですが
on your computer, but without forcing you to use
コマンドラインを使うことなくコミットができます
the command line. You edit your files with a text editor
テキストエディタでファイルを いつもどおり編集したら
the way you normally would, but now, GitHub for Desktop,
今度は GitHub デスクトップで―
and I'm showing you the Mac version here, will let you select
―ここでは Mac 版でご紹介しますね
which files you want to stage and then commit.
ステージングするファイルを選んで コミットします
You can easily select the files you want to be in the commit
コミットしたいファイルが簡単に選べて メッセージを入力します
and type in the message, and GitHub for Desktop handles
あとは GitHub デスクトップが add とcommit を行います
the add and the commit for you. This is another great way
ふだんの操作でコマンドラインを使わない いい方法ですね
to go if you want to steer clear of the command line for
コミットは Git と GitHub のコラボレーションでは いしずえとなるものです
everyday operations. Commits are the cornerstone of collaboration
さて 今後のエピソードでは ローカルで行ったコミットの検証
with Git and GitHub. In future episodes, we'll look at how
そして一番面白いのが 他の人とシェアする方法を見ていきます
to examine the commits you have locally, and, the best part,
[ありがとうございました]
how to share them with other people.
GitHub の基礎 コミットについて ご覧いただきありがとうございました
[Thanks for watching.]
お気に入りいただけたら こちらの GitHub ガイドもどうぞご登録ください
Thanks for watching this episode of GitHub Foundations
GitHub の他のビデオも ありますので
on how to commit. If you like this, subscribe
こちらから他のチャンネルも ご覧ください
to the GitHub Guides channel here. If you want to see
いつものように質問やコメントを お待ちしています
other things we've got going on with videos at GitHub,
下記に書き込んでください
check out our other channels down here.
他のトレーニングビデオは こちらをクリックしてみてください
As always, we would love if you left us a comment or
a question down here, and if you want to see more
training videos, just click on one of these guys
down here; we got them ready for you.