Gitステージング環境
Gitステージング環境
Gitのコア機能の1つは、ステージング環境とコミットの概念です。
作業中に、ファイルを追加、編集、および削除している可能性があります。ただし、マイルストーンに到達したり、作業の一部を終了したりするときはいつでも、ファイルをステージング環境に追加する必要があります。
ステージングされたファイルは、作業中のリポジトリに
コミットする準備ができているファイルです。commit
間もなく詳細を学びます
。
今のところ、での作業は完了index.html
です。したがって、ステージング環境に追加できます。
例
git add index.html
ファイルはステージングされている必要があります。ステータスを確認しましょう::
例
git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: index.html
これで、ファイルがステージング環境に追加されました。
Gitは複数のファイルを追加します
一度に複数のファイルをステージングすることもできます。作業フォルダにさらに2つのファイルを追加しましょう。もう一度テキストエディタを使用してください。
リポジトリを説明するREADME.md
ファイル(すべてのリポジトリに推奨):
例
# hello-world
Hello World repository for Git tutorial
This is an
example repository for the Git tutoial on https://www.w3schools.com
This repository is built step by step in the tutorial.
基本的な外部スタイルシート(bluestyle.css
):
例
body {
background-color: lightblue;
}
h1 {
color: navy;
margin-left: 20px;
}
index.html
そして、スタイルシートを含めるように更新します。
例
<!DOCTYPE html>
<html>
<head>
<title>Hello World!</title>
<link
rel="stylesheet" href="bluestyle.css">
</head>
<body>
<h1>Hello world!</h1>
<p>This is
the first file in my new Git Repo.</p>
</body>
</html>
次に、現在のディレクトリ内のすべてのファイルをステージング環境に追加します。
例
git add --all
--all
個々のファイル名の代わりに使用するとstage
、すべての変更(新規、変更、および削除)ファイルが作成されます。
例
git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: README.md
new file: bluestyle.css
new file: index.html
これで、3つのファイルすべてがステージング環境に追加され、最初のファイルを作成する準備が整いましたcommit
。
注:の省略コマンド
git add --all
はgit add -A