LoginSignup
0
1

More than 5 years have passed since last update.

git for windows 初めてのadd,commit

Last updated at Posted at 2016-07-09

まずはファイルを作ってaddしてみよう

現状の確認

$ git status
On branch master

Initial commit

nothing to commit (create/copy files and use "git add" to track)

現状は空っぽです。

ファイルを新しく作る

$ touch read.me
$ git status
On branch master

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        read.me

nothing added to commit but untracked files present (use "git add" to track)

touchはファイルのタイムスタンプを変更するコマンドですが、空のファイルを作ることもできます。
ステイタスを見ると「read.me」は「Untracked files」とでてきます。これはリポジトリで管理されていないファイルということです。

登録してみる

$ git add read.me
$ git status
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   read.me

git addコマンドでステージ領域(コミットをする前の一時領域)へ登録します。

commitしてみよう

commitしてみる

$ git commit -m "my  first commit"
[master (root-commit) 4833fd1] my  first commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 read.me
$ git status
On branch master
nothing to commit, working directory clean

git commitコマンドでコミットします-mはコミット内容の概要を追加するオプションです。
git statusを確認するとread.meがなくなってしまいました。これはワーキングディレクトリ、つまり作業中のファイルはないよってことで、read.meはリポジトリにいます。

ファイルはディレクトリにありますよ

$ ls
read.me

logを見てみる

$ git log
commit 4833fd1ad12c674fb6d4583afb59a11193e759b4
Author: firstname lastname <your_email@example.com>
Date:   Sat Jul 9 12:25:18 2016 +0900

    my  first commit

logをみればcommitできていることがわかります。
4833fd・・・はハッシュです、コミットの番号です。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1