Windowsにgit導入、cygwinで利用してみる。
wordpressのバージョン管理の為、gitを導入。
何気にバージョン管理はSVNしか利用した事無かったので今更のgitデビューです。
とりあえず、今回はWindows環境にてローカルでリポジトリ作成。
操作はpoderosaから行いたい為、設定や実行はcygwinにて。
前提作業としてcygwinのインストール時にgit関連インストールも行います。
環境
Windows7 64bit
手順
自分用メモなので必要部分だけ纏め
gitダウンロード
gitの初期設定
で、こっからcygwinで操作
と思いきや早速こけたのでGitBash利用。
cygwinで実行するとエラー発生したのでGitBashで実行
$ git config --global user.name "<ユーザ名>" $ git config --global user.email "<メールアドレス>"
カラーリングするように設定。
これもGitBashから
$ git config --global color.ui auto
ここからはcygwinで実行
新規リポジトリ作成。
ここでは/tmp/gittest/というディレクトリにリポジトリを作成。
$ mkdir /tmp/gittest/ $ cd /tmp/gittest/ $ git init Initialized empty Git repository in /tmp/gittest/.git/
gitの状態確認
$ git status On branch master Initial commit nothing to commit (create/copy files and use "git add" to track)
何かよくわからないメッセージ出た。
訳すると、コミットデータが無いですよーって感じ?
まずはインデックスにデータを追加してみる
$ touch ./commit.txt $ git add ./commit.txt
状態を確認すると新しいファイルcommit.txtがありますよと出てる
問題なく追加できたみたい
$ git status On branch master Initial commit Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: commit.txt
続いてコミット
$ git commit -m "初コミット!" *** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: unable to auto-detect email address (got '@')
なんかエラーメッセージ出た
メールアドレスとユーザーを指定しろという事らしい。
・・・GitBashでやったのですが。
どうやらGitBashとcygwinでは別という事?
cygwinからはコマンド実行エラーなるので、
結局直接エディタで設定する事に
C:\Users\hoge\.gitconfig
[core] autocrlf = true [user] name = hoge email = hoge@gmail.com [color] ui = auto
あれ、設定されてる。。
もっかいcygwinからユーザー作成
$ git config --global user.name "hoge" error: could not lock config file C:\cygwin\home\hoge/.gitconfig: Permission denied
権限関連でエラー
下記リンクを参考にC:\cygwin\home\hogeの権限設定
所有権の取得方法・所有者を変更してもアクセス許可が出ません - マイクロソフト コミュニティ
権限変更後はcygwin上からgitの設定ファイル作成出来た。
$ git config --global user.email "hoge@hoge.com" $ git config --global user.name "hoge"
コミットしてみる。
$ git commit -m "初コミット!" [master (root-commit) 8397c7a] 初コミット! 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 commit.txt\
出来た~
コミットまで完了。
今日はここまで