githubリポジトリに、ディレクトリやファイルを追加する
apache/htdocs に ローカルリポジトリを置く
$ git config --global user.name "example" $ git config --global user.email (メールアドレス) $ mkdir c:\\Apache\\htdocs\\github $ cd c:\\Apache\\htdocs\\github $ git init $ touch README $ git add README $ git commit -m 'hello github' $ git remote add origin git@github.com:example/example.git $ git push origin master
リポジトリにファイルを追加する
$ touch add.php $ git add add.php $ git commit -m 'test commit' $ git push origin master
リポジトリにディレクトリを追加する
$ git add numnet/test.php $ git commit -m "test commit" $ git push origin master
カレントディレクトリ 再帰的に追加
$ git add .
追加を確認する
$ git show
$HOMEは、git/etc/profile にあります。
$HOMEを変更すると、公開鍵を新しく作ることになります。
※ ~/local/github/ は、C:\Documents and Settings\ログイン名\local\github なんかになります。
※ 作業を始めるときには、ローカルリポジトリの作業場所に、必ず cd してから作業をしないと、パスワードが読めないとかエラーが発生します。動作するコマンドもあるので、公開鍵に問題があるように思えたりして、勘違いしやすい。
エディタを秀丸エディタに変更
git config --global core.editor 'c:/Program Files/hidemaru/hidemaru.exe'
git commit -m 'iroiro' としないで、git commit -aとするとエディタが開いてきます。
コミットしたら、そのまま秀丸は、保存して終了してGitBashに戻ります。 utf-8必須
やってみると、
githubのリポジトリは、日本語になりましたが、コマンドラインは文字化けしている
$ git commit -a [master 0fd8e94] 譌・譛ャ隱 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 numnet/rensyu.php
ファイルの削除
$ git rm 'add.php' $ git commit -m 'remove' $ git push
公開鍵と秘密鍵を作る
Help.GitHub - Generating SSH keys (Win/msysgit)
$ ssh-keygen -t rsa -C "tekkub@gmail.com" Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/Tekkub/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/Tekkub/.ssh/id_rsa. Your public key has been saved in /c/Users/Tekkub/.ssh/id_rsa.pub. The key fingerprint is: e8:ae:60:8f:38:c2:98:1d:6d:84:60:8c:9e:dd:47:81 tekkub@gmail.com
ローカルに出来た id_rsa.pubをテキストエディタで開いて、github の Account Settings SSH Public Key にコピペします。
現在の構成にタグをつける
$ git tag -a v0.11 -m 'my version 0.11' $ git tag 0.1 v0.1 v0.11 $ git push origin v0.11
必ずpushしないとgithubに反映しない
githubのファイルを直で表示
https://github.com/tenman/(リポジトリ名)/raw/(tag)/(ファイル名)
gist 最新版のrow data
例えば、https://gist.github.com/627325ならばhttps://gist.github.com/627325.txtでアクセスできる
リポジトリを削除する
ブランチの作成とマージ
myselfブランチを作成する
$ git branch myself
ブランチ一覧で、確認する
$ git branch * master myself
masterからmyselfへ切り替える
$ git checkout myself Switched to branch 'myself'
gitは、切り替わっていますが、Windowsに新しいホルダが作られるわけではありません。masterの時とまったく同じものにしか見えません
windowのファイル操作を行って、ブランチがどのような機能なのか、実際にやってみるとわかりやすい。
windowsのファイルを、なんか適当に、書き換えます。出来たら、
git commit -a
テキストエディタが開いて、変更したファイルの前にあるコメントをはずして、保存エディタを閉じる
ブランチをmasterに切り替える
$ git checkout master Switched to branch 'master'
切り替えたら、さっき変更したファイルを開いてみる。
変更する前のファイルになっていると思う。
checkoutする事3回目で「ブランチ」すごいとわかりました
ブランチをマージする
$ git merge myself Updating 8d9c338..56467da Fast forward wp-content/themes/raindrops/header.php | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
$ git push origin master
で終わり
ブランチが、マスターの最新版につながっている必要があるとき
$ git checkout myself Switched to branch 'myself' $ git rebase master
最新版のブランチになる
コンフリクトしたら、
直して
$ git rebase --continue
やっちまったと思った時は
$ git rebase --abort
間違い
作業ツリーを最後にコミットした状態に戻す
$ git reset --hard HEAD