&tag(git);
*目次 [#x329001c]
#contents
*関連情報 [#s71ea7b7]
-[[git]] / [[github]]

*日々の運用 [#q1580307]
**ローカルリポジトリの作成 [#g20f9c3b]
-プロジェクトディレクトリでローカルリポジトリを作成してコミットする
#pre{{
$ cd <PROJECT_HOME>
$ git init
$ git add .
$ git commit -a -m "first commit"
}}
**リモートリポジトリの作成 [#p4227c9b]
- /home/repository/sample.gitディレクトリに空のリポジトリを作成する。
#pre{{
$ mkdir -p /home/repository/sample.git
$ cd /home/repository/sample.git
$ git --bare init
}}
-オリジナルワークツリーの内容をpush
#pre{{
$ cd <PROJECT_HOME>
$ git remote add origin /pub/repository/sample.git master
$ git push origin master
}}
-二カ所目でclone 
#pre{{
$ git clone firstmac:/pub/repository/sample.git
}}
*編集→コミットまでの流れ [#cc21f3a6]
-ファイル編集
- 新規ファイルがある場合はgit add . 
- git commit -a

*サブモジュールを使う [#mae9fb07]
-[[git submodule - みずぴー日記:http://d.hatena.ne.jp/mzp/20080508/git]]
-[[[git 1.6.0.2] submoduleを使おう!その1:add, status - satoko's blog - s21g:http://blog.s21g.com/articles/1401]]
-[[[git 1.6.0.2] submoduleを使おう!その2 - satoko's blog - s21g:http://blog.s21g.com/articles/1411]]


*空フォルダを管理する [#xd050ab3]
-フォルダに空の.gitignoreファイルを置く。

*Subversionからの移行 [#a958bb0c]
-Windows以外の環境は安定してるようなのでWindowsがからまないなら使っても良さそう。Windows用クライアントはいろいろとだめ。
-GUIクライアントはなくてもまあ大丈夫か。
-[[SubversionからGitへの移行をオススメする7つの理由 - akimatter:http://d.hatena.ne.jp/akm/20100227/1267289900]]

*戻したい [#i2bacc30]
-[[gitでアレを元に戻す108の方法 - TIM Labs:http://labs.timedia.co.jp/2011/08/git-undo-999.html]]

**最後にcommitした状態にもどしたい [#c8104ecf]
-checkoutした状態に戻したい場合など
 git reset --hard HEAD
-ゴミがある場合(gitで管理していないファイルが追加されてた場合)。
 git clean -df

**過去のcommitに戻したい [#n2b3eee0]
-以前のcommitに戻したい場合、git logなどで確認して
 git reset --heard xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*git pullでコンフリクトしたときの対処法 [#g0fb6122]
** 参考情報 [#aed6b68f]
-[[Force git to overwrite local files on pull. - Stack Overflow:http://stackoverflow.com/questions/1125968/force-git-to-overwrite-local-files-on-pull]]

** 前回git pullした状態に戻す [#v769389d]
-一回もローカルリポジトリにcommitしてない場合 
 git reset HEAD
-ローカルファイルに変更があってそれもなくす場合
 git reset --hard HEAD
-一回コミットしていた場合は、HEADの場合にHEAD^を使えばよい。

git logなどして確認する。


*ベンダーブランチの管理 [#ba9d78b7]

**Gitで管理されていない上流ソースの管理 [#r49c7e66]
-[[Vendor branches in git | Jabbering Giraffe:http://happygiraffe.net/blog/2008/02/07/vendor-branches-in-git/]] //例としてWordPressが取り上げられている。テーマを管理しようとするときにも役に立つかもしれない(→自分用に翻訳)
-[[How do I import a third party lib into git? - Stack Overflow:http://stackoverflow.com/questions/1695925/how-do-i-import-a-third-party-lib-into-git]]
-そのソース用に専用gitリポジトリを作って毎回インポートしなおす戦略。使用する側はそのgitリポジトリをサブモジュールとして参照。
**Gitで管理されているソースの管理 [#jc067ce0]
-submoduleで管理するのが簡単?[[[git 1.6.0.2] submoduleを使おう!その2 - satoko's blog - s21g:http://blog.s21g.com/articles/1411]]。forkしてから組み込むことで上流の変更にも追随できる。


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS