Created
November 10, 2010 09:30
-
-
Save akkunchoi/670603 to your computer and use it in GitHub Desktop.
Revisions
-
akkunchoi revised this gist
Jun 27, 2012 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,7 @@ つづきはこちらで <http://akkunchoi.github.com/git-ref.html> Git 基本(とりあえずこれ覚えればOK) -
akkunchoi revised this gist
Jun 27, 2012 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -168,13 +168,17 @@ origin/serverfix が指す先から作業を開始するためのローカルブ fetch とmergeを自動でやってくれる $ git pull $ git pull --rebase # mergeではなくrebaseします。ちょっとしたローカルの変更がある場合に リモートブランチを削除しても、別の場所してクローンされてるとずっと残る。追加は自動だけど削除は自動でしてくれない。そういう場合に prune を使う。 # 状態を確認する $ git remote show origin $ git remote prune origin リポジトリを破壊します! $ git push --force origin master サブモジュール -
akkunchoi revised this gist
Jun 27, 2012 . 1 changed file with 8 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,5 @@ Git 基本(とりあえずこれ覚えればOK) ----------------------------- @@ -444,4 +442,11 @@ git pullでremoteを自動的に指定 * fixup は一つ前のコミットと結合する。コミットメッセージは前のが使われる。 * exec はshellを走らせるらしい。 で、行を消すとそのコミットが失われる。でも全部消すとrebaseは中止になる。 参考 ================ - [Gitをボトムアップから理解する](http://keijinsonyaban.blogspot.jp/2011/05/git.html) - [Git Branching Model](http://keijinsonyaban.blogspot.jp/2010/10/successful-git-branching-model.html) -
akkunchoi revised this gist
Jun 27, 2012 . 1 changed file with 22 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ Git http://keijinsonyaban.blogspot.jp/2011/05/git.html 基本(とりあえずこれ覚えればOK) ----------------------------- @@ -31,6 +33,16 @@ commit --amend や reset --hard HEAD^^ とかして見えなくなったコミ コミット ------- svn commitとだいたい等価。gitはコミット前にadd(ステージング)が必要。 $ git add hoge.txt $ git commit -m "commit message" といっても、add するのが面倒な時は -a オプションで $ git commit -a hoge.txt 直前のコミットをやり直しできる! $ git commit --amend @@ -40,13 +52,22 @@ commit --amend や reset --hard HEAD^^ とかして見えなくなったコミ $ git reset --hard HEAD^ $ git reflog # HEAD履歴を確認できる。間違えた場合はそれも戻せる ステージング $ git add hoge.txt $ git add -p hoge.txt # interactiveに部分的なステージングができる ステージングの取り消し $ git reset HEAD hoge.txt svn revertのようなもの。ステージングしていない変更の取り消し。 $ git checkout -- hoge.txt $ git checkout -- . # こうするとカレントディレクトリ以下の全更新が消えるよ $ git checkout -p hoge.txt # interactiveに操作する ブランチ -
akkunchoi revised this gist
May 9, 2012 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -181,6 +181,13 @@ submoduleのあるリポジトリをcloneした後、 .gitmodulesを見ればわかる サブモジュールを削除 .git/config の該当モジュールを削除 $ git rm --cached path/to/hoge $ git commit git-svn ------------ -
akkunchoi revised this gist
Apr 30, 2012 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -83,6 +83,10 @@ rebaseはmergeとrebaseの違いは後述 $ git cherry-pick {commit} マージを取り消す $ git reset --hard HEAD タグ ------- -
akkunchoi revised this gist
Mar 12, 2012 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -404,6 +404,7 @@ git pullでremoteを自動的に指定 この行を修正して保存することで、指示通りにrebaseが行われる。 コマンドはコメントに書かれてある。 * pick はそのままコミットを使う * reword は保存後にrebaseが走るので、その時にコミットメッセージを変更するエディタが走る。(注:rebase -i した中でのコメントを変更するのではない。) * edit はamendするためにストップする?よくわからん。 -
akkunchoi revised this gist
Mar 12, 2012 . 1 changed file with 37 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -375,3 +375,40 @@ git pullでremoteを自動的に指定 $ git push -u origin master コミットの圧縮 ---------------- マージするときにひとつのコミットにまとめる。 git merge --squash something-new-feature または git rebase -i でsquash する。(後述) すでにコミットしたものを操作する。(git rebase -i) ---------------- # コミット2つあったとする git commit -am "hoge" git commit -am "moge" git rebase -i head^^ するとエディターが開かれる。 pick 59d6190 hoge pick 0149644 moge # Rebase 36fde72..0149644 onto 36fde72 # ... この行を修正して保存することで、指示通りにrebaseが行われる。 コマンドはコメントに書かれてある。 * pick はそのままコミットを使う * reword は保存後にrebaseが走るので、その時にコミットメッセージを変更するエディタが走る。(注:rebase -i した中でのコメントを変更するのではない。) * edit はamendするためにストップする?よくわからん。 * squash は一つ前のコミットと結合する。コミットメッセージはrebaseで選択する。 * fixup は一つ前のコミットと結合する。コミットメッセージは前のが使われる。 * exec はshellを走らせるらしい。 で、行を消すとそのコミットが失われる。でも全部消すとrebaseは中止になる。 -
akkunchoi revised this gist
Feb 14, 2012 . 1 changed file with 14 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -308,15 +308,26 @@ mergeはブランチの履歴を残して一本にするけど、rebaseすると その他 ================ # # コンフリクト状態が残ってしまった場合 # $ git pull You have not concluded your merge (MERGE_HEAD exists). Please, commit your changes before you can merge $ git reset --merge # # mergeを実行したらconflictが大量に出てしまったので取り消したい # $ git reset --hard ORIG_HEAD # # Untrackedなファイルを取り除きたい # $ git clean -f git pullでremoteを自動的に指定 ---------------- @@ -364,7 +375,3 @@ git pullでremoteを自動的に指定 $ git push -u origin master -
akkunchoi revised this gist
Feb 14, 2012 . 1 changed file with 17 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -320,8 +320,11 @@ mergeはブランチの履歴を残して一本にするけど、rebaseすると git pullでremoteを自動的に指定 ---------------- # # remoteが指定されてない(trackしてない)場合はリモート指定なしで git pull しても「わからないよ」と言われる # (master) $ git pull You asked me to pull without telling me which branch you want to merge with, and 'branch.master.merge' in your configuration file does not tell me, either. Please @@ -342,13 +345,26 @@ git pullでremoteを自動的に指定 See git-config(1) for details. # 解決法1 # 手動で指定 # (master) $ git pull origin master # 解決法2 # configで指定 # $ vi .git/config [branch "master"] remote = origin merge = refs/heads/master # 解決法3 # これだけでOK $ git push -u origin master mergeを実行したらconflictが大量に出てしまったので取り消したい ---------------- $ git reset --hard ORIG_HEAD -
akkunchoi revised this gist
Jan 15, 2012 . 1 changed file with 47 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -305,3 +305,50 @@ A'' の HEAD^ は B mergeはブランチの履歴を残して一本にするけど、rebaseすると履歴も含めて一本に作り直す。そのためrebaseは注意が必要。 その他 ================ コンフリクト状態が残ってしまった場合 ---------------- $ git pull You have not concluded your merge (MERGE_HEAD exists). Please, commit your changes before you can merge $ git reset --merge git pullでremoteを自動的に指定 ---------------- (master) $ git pull You asked me to pull without telling me which branch you want to merge with, and 'branch.master.merge' in your configuration file does not tell me, either. Please specify which branch you want to use on the command line and try again (e.g. 'git pull <repository> <refspec>'). See git-pull(1) for details. If you often merge with the same branch, you may want to use something like the following in your configuration file: [branch "master"] remote = <nickname> merge = <remote-ref> [remote "<nickname>"] url = <url> fetch = <refspec> See git-config(1) for details. # 手動で指定 (master) $ git pull origin master # configで指定 $ vi .git/config [branch "master"] remote = origin merge = refs/heads/master -
akkunchoi revised this gist
Dec 21, 2011 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -146,6 +146,13 @@ fetch とmergeを自動でやってくれる $ git pull リモートブランチを削除しても、別の場所してクローンされてるとずっと残る。追加は自動だけど削除は自動でしてくれない。そういう場合に prune を使う。 # 状態を確認する $ git remote show origin $ git remote prune origin サブモジュール ------------ -
akkunchoi revised this gist
Oct 19, 2011 . 1 changed file with 14 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -208,27 +208,26 @@ svnにタグ作成 $ git svn tag new_tag_name FAQ - git-svn dcommit できなかったのでコミットID見たら、違うIDになってた...。 - > patch を作成する - ローカルに未コミットの変更があるけどgit-svn-dcommitしたい - > stashを使う $ git stash $ git svn dcommit $ git stash apply - svn:externalsのようなことをしたい - > git submodule 移行スクリプト。でもうまくいかなかった… http://github.com/garbas/garbasgit.svnexternals (via http://d.hatena.ne.jp/Sixeight/20090210/1234272295 ) - 空のディレクトリはバージョン管理できない - > .gitignoreとか何でもいいから空ファイルを作成すればOK。 - 複数のモジュールを含むSubversionリポジトリをGitへ移行する。http://iteman.jp/blog/2009/02/subversiongit.html 他注意点 -
akkunchoi revised this gist
Oct 19, 2011 . 1 changed file with 38 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -174,7 +174,9 @@ submoduleのあるリポジトリをcloneした後、 git-svn ------------ http://progit.org/book/ja/ch8-1.html http://d.hatena.ne.jp/idesaku/20090323/1237825080 svn checkoutのようなもの svnからgitリポジトリを作成。 -s(standard)オプションはsvnのtrunk/branches/tags構成をそのままインポートする $ git svn clone file:///tmp/test-svn -s @@ -183,10 +185,12 @@ svnのデータだけ取得 $ git svn fetch svn upのようなもの svnのデータを取り込む $ git svn rebase svn commitのようなもの svnにコミット。gitのコミットIDが書き換わる!注意! コミットできたらgit-svn-id属性が付く。 @@ -204,9 +208,43 @@ svnにタグ作成 $ git svn tag new_tag_name git-svn dcommit できなかったのでコミットID見たら、違うIDになってた...。 -> patch を作成する ローカルに未コミットの変更があるけどgit-svn-dcommitしたい -> stashを使う $ git stash $ git svn dcommit $ git stash apply svn:externalsのようなことをしたい -> git submodule 移行スクリプト。でもうまくいかなかった… http://github.com/garbas/garbasgit.svnexternals (via http://d.hatena.ne.jp/Sixeight/20090210/1234272295 ) 空のディレクトリはバージョン管理できない -> .gitignoreとか何でもいいから空ファイルを作成すればOK。 複数のモジュールを含むSubversionリポジトリをGitへ移行する http://iteman.jp/blog/2009/02/subversiongit.html 他注意点 - 部分的なチェックアウトできない - svn checkout はパスを指定すればどの階層でもワーキングコピーを作成できる。 git clone すると今までの履歴含め、全てをコピーしなければならない。 なのでプロジェクト/モジュールごとにリポジトリを作成するのがベストだろう。 - ディレクトリ同士のマージができない。これはどうにもできないかも。 - trunk, branches, tags - Subversionはディレクトリ構造として表現 - Gitはbranchesとtagsが別のシステムになっている。 パッチ ------------ http://blog.s21g.com/articles/680 直前のコミットとその前との差分でパッチを作成する -
akkunchoi revised this gist
Oct 18, 2011 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -217,7 +217,7 @@ svnにタグ作成 $ git am 0001-hoge.patch git merge と git rebaseの違い ---------------- masterのHEADはポイントAにあるとする @@ -228,13 +228,13 @@ Aからブランチしたworkingを作成し、Bまで進める (master) ---A \ (working) \----- B そこからさらに masterでも変更し A' まで進めたとする (master) -- A ------------ A' \ (working) \----- B この状態で、 @@ -258,3 +258,6 @@ A'' の HEAD^ は B \ / (working) \-----B mergeはブランチの履歴を残して一本にするけど、rebaseすると履歴も含めて一本に作り直す。そのためrebaseは注意が必要。 -
akkunchoi revised this gist
Oct 18, 2011 . 1 changed file with 25 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -74,6 +74,15 @@ testingブランチを作成(切り替えはしない) $ git merge --no-squash issue53 # 変更をワーキングツリーに適用する。マージもコミットもしない。ブランチ上での履歴は無くなる。 $ git merge --no-ff issue53 # [ToDo] mergeは二本に分かれた枝を一本に合わせる。 rebaseはmergeとrebaseの違いは後述 $ git rebase master あるコミットの変更分だけを適用する $ git cherry-pick {commit} タグ ------- @@ -221,32 +230,31 @@ Aからブランチしたworkingを作成し、Bまで進める \ (working) \-----B そこからさらに masterでも変更し A' まで進めたとする (master) -- A ------------ A' \ (working) \-----B この状態で、 (master) git merge working した場合 A'に B がマージされて C になる。 C の HEAD^(一つ前) は A' (master) ---A ------------ A' ---- C \ / (working) \-----B------------ (master) git rebase working した場合 コミットA'の存在はmasterからはなくなって、 Bからの続きとして AからA'の差分がマージされて A'' になる A'' の HEAD^ は B First, rewinding head to replay your work on top of it... Applying: commit B (master) ---A ------ A'' \ / (working) \-----B -
akkunchoi revised this gist
Oct 18, 2011 . 1 changed file with 45 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -72,8 +72,8 @@ testingブランチを作成(切り替えはしない) $ git merge issue53 $ git merge --no-commit issue53 # "Merged branch ..." とコミットされるが、それをしない $ git merge --no-squash issue53 # 変更をワーキングツリーに適用する。マージもコミットもしない。ブランチ上での履歴は無くなる。 $ git merge --no-ff issue53 # [ToDo] タグ ------- @@ -92,6 +92,7 @@ testingブランチを作成(切り替えはしない) タグの共有 $ git push origin v1.5 $ git push origin --tags # 共有されてないもの全部 $ git push origin :missing_tag # リモートのタグを削除 共有 ---------- @@ -207,3 +208,45 @@ svnにタグ作成 $ git am 0001-hoge.patch git merge と git rebaseの違い。 ---------------- masterのHEADはポイントAにあるとする (master) ---A Aからブランチしたworkingを作成し、Bまで進める (master) ---A \ (working) \-----B ここまでだったら (master) git merge working で workingの変更をmergeできる。 そこからさらに masterでも変更し A'まで進めたとする (master) ---A -------------A' \ (working) \-----B (master) git merge working ではmergeできない fatal: You have not concluded your merge (MERGE_HEAD exists). Please, commit your changes before you can merge. (master) git rebase working する First, rewinding head to replay your work on top of it... Applying: commit1 Applying: commit2 するとこうなる (master) ---A ------A'' \ / (working) \-----B コミットA'の存在はmasterからはなくなって、 Bからの続きとして AからA'の差分がマージされて A''になる -
akkunchoi revised this gist
Oct 4, 2011 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,6 +24,11 @@ http://progit.org/book/ja/ch2-3.html $ git log --since=2.weeks # 日付指定 $ git log -(n) # n件 commit --amend や reset --hard HEAD^^ とかして見えなくなったコミットを確認する $ git reflog コミット ------- 直前のコミットをやり直しできる! -
akkunchoi revised this gist
Sep 19, 2011 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,7 @@ Git ----- http://progit.org/book/ja/ch2-3.html $ git log -p # diffも出力する $ git log --stat # 変更したファイルの一覧 $ git log --pretty=oneline #1行で @@ -160,35 +161,44 @@ git-svn http://progit.org/book/ja/ch8-1.html svnからgitリポジトリを作成。 -s(standard)オプションはsvnのtrunk/branches/tags構成をそのままインポートする $ git svn clone file:///tmp/test-svn -s svnのデータだけ取得 $ git svn fetch svnのデータを取り込む $ git svn rebase svnにコミット。gitのコミットIDが書き換わる!注意! コミットできたらgit-svn-id属性が付く。 $ git svn dcommit git-svnで削除されたリモートブランチをローカルでも削除する方法 $ git branch -r -d my-remote-branch svnにブランチ作成 $ git svn branch new_branch_name svnにタグ作成 $ git svn tag new_tag_name パッチ ------------ 直前のコミットとその前との差分でパッチを作成する $ git format-patch -r HEAD~ パッチを適用する $ git am 0001-hoge.patch -
akkunchoi revised this gist
Sep 19, 2011 . 1 changed file with 9 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ Git 基本(とりあえずこれ覚えればOK) ----------------------------- $ git init hoge # git リポジトリを作成。または... @@ -60,7 +60,13 @@ testingブランチを作成(切り替えはしない) $ git checkout -b issue53 マージする 通常はFast forward ポインタを前に進めるだけ。 $ git merge issue53 $ git merge --no-commit issue53 # "Merged branch ..." とコミットされるが、それをしない $ git merge --no-squash issue53 # 変更をワーキングツリーに適用する。マージもコミットもしない。ブランチ上での履歴は無くなる。 タグ ------- @@ -73,7 +79,7 @@ Fast forward ポインタを前に進めるだけ。 $ git tag v0.1 注釈付きタグの作成(コミットするかどうかの違いらしいが、どう使い分けるのか分からん) $ git tag -a v1.4 -m 'my version 1.4' -
akkunchoi revised this gist
Mar 19, 2011 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,6 +29,11 @@ http://progit.org/book/ja/ch2-3.html $ git commit --amend 直前のコミットをなかった事にして一つ前のコミット状態に戻す $ git reset --hard HEAD^ $ git reflog # HEAD履歴を確認できる。間違えた場合はそれも戻せる ステージングの取り消し $ git reset HEAD hoge.txt -
akkunchoi revised this gist
Feb 10, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -178,6 +178,6 @@ svnにタグ作成 $ git format-patch -r HEAD~ パッチを適用する $ git am 0001-hoge.patch -
akkunchoi revised this gist
Feb 10, 2011 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -170,3 +170,14 @@ svnにブランチ作成 svnにタグ作成 $ git svn tag new_tag_name パッチ ------------ 直前のコミットとその前との差分でパッチを作成する $ git format-patch -r HEAD~ パッチを適用する $ git-am 0001-hoge.patch -
akkunchoi renamed this gist
Feb 10, 2011 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ Git 基本(とりあえずこれ覚えればOK?) ----------------------------- @@ -161,4 +161,12 @@ svnにコミット。gitのコミットIDが書き換わる!注意! コミットできたらgit-svn-id属性が付く。 $ git svn dcommit git-svnで削除されたリモートブランチをローカルでも削除する方法 $ git branch -r -d my-remote-branch svnにブランチ作成 $ git svn branch new_branch_name svnにタグ作成 $ git svn tag new_tag_name -
akkunchoi revised this gist
Nov 10, 2010 . 1 changed file with 19 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -143,3 +143,22 @@ submoduleのあるリポジトリをcloneした後、 .gitmodulesを見ればわかる git-svn ------------ http://progit.org/book/ja/ch8-1.html svnからgitリポジトリを作成。 -s(standard)オプションはsvnのtrunk/branches/tags構成をそのままインポートする $ git svn clone file:///tmp/test-svn -s svnのデータだけ取得 $ git svn fetch svnのデータを取り込む $ git svn rebase svnにコミット。gitのコミットIDが書き換わる!注意! コミットできたらgit-svn-id属性が付く。 $ git svn dcommit -
akkunchoi revised this gist
Nov 10, 2010 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,17 @@ 逆引きGit 基本(とりあえずこれ覚えればOK?) ----------------------------- $ git init hoge # git リポジトリを作成。または... $ git clone [email protected]:myrepo.git # 外部から取得 ... some change $ git add * $ git commit -m "my commit" $ git status # 状態を見る $ git push origin master # remoteに送信 $ git pull ログ ----- -
akkunchoi revised this gist
Nov 10, 2010 . 1 changed file with 28 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ ログ ----- http://progit.org/book/ja/ch2-3.html $ git log -p # diffも出力する $ git log --stat # 変更したファイルの一覧 $ git log --pretty=oneline #1行で @@ -25,6 +26,7 @@ svn revertのようなもの ブランチ --------- http://progit.org/book/ja/ch3-1.html HEADは「あなたが作業しているローカルブランチへのポインタ」 testingブランチを作成(切り替えはしない) @@ -63,6 +65,8 @@ Fast forward ポインタを前に進めるだけ。 共有 ---------- http://progit.org/book/ja/ch3-5.html 「こっちの serverfix で、リモートの awesomebranch を更新しろ」 $ git push origin serverfix:awesomebranch @@ -101,3 +105,27 @@ fetch とmergeを自動でやってくれる $ git pull サブモジュール ------------ http://progit.org/book/ja/ch6-6.html $ git submodule add git://github.com/chneukirchen/rack.git rack submoduleのあるリポジトリをcloneした後、 $ git submodule init $ git submodule update サブモジュールの外部の変更を取り込むには毎回これをやる $ git merge origin/master $ git submodule update サブモジュールはあるポイントしか見ない!!親プロジェクトはそのポイントを記録する 問題点。特定のバージョンをポイントしている(detached head)ので、git submodule updateで手元の変更が失われやすい .gitmodulesを見ればわかる -
akkunchoi revised this gist
Nov 10, 2010 . 1 changed file with 87 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,49 @@ ログ ----- $ git log -p # diffも出力する $ git log --stat # 変更したファイルの一覧 $ git log --pretty=oneline #1行で $ git log --pretty=format:"%h - %an, %ar : %s" # 独自のフォーマットで $ git log --since=2.weeks # 日付指定 $ git log -(n) # n件 コミット ------- 直前のコミットをやり直しできる! $ git commit --amend ステージングの取り消し $ git reset HEAD hoge.txt svn revertのようなもの $ git checkout -- hoge.txt ブランチ --------- HEADは「あなたが作業しているローカルブランチへのポインタ」 testingブランチを作成(切り替えはしない) $ git branch testing 切り替える $ git checkout testing 作成して切り替える $ git checkout -b issue53 Fast forward ポインタを前に進めるだけ。 タグ ------- タグの一覧 $ git tag @@ -14,3 +60,44 @@ $ git push origin v1.5 $ git push origin --tags # 共有されてないもの全部 共有 ---------- 「こっちの serverfix で、リモートの awesomebranch を更新しろ」 $ git push origin serverfix:awesomebranch $ git push origin master $ git push # 省略できる リモートにデータを送信 「こっちの (何もなし) で、向こうの [remotebranch] を更新しろ」 ドッカーン。これでブランチはサーバーから消えてしまいました。 $ git push origin :serverfix リモートのデータを取得 $ git fetch origin fetchしたものとマージ $ git merge origin/master origin/serverfix が指す先から作業を開始するためのローカルブランチができあがりました。 $ git checkout -b serverfix origin/serverfix 追跡ブランチ: cloneすると自動的に追跡ブランチする。これが引数なしでgit pushやgit pullが動作する理由。 これは同じ意味。 $ git checkout --track origin/serverfix $ git checkout -b serverfix origin/serverfix fetch とmergeを自動でやってくれる $ git pull -
akkunchoi created this gist
Nov 10, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ タグの一覧 $ git tag タグを作成 $ git tag v0.1 注釈付きタグの作成 $ git tag -a v1.4 -m 'my version 1.4' タグの共有 $ git push origin v1.5 $ git push origin --tags # 共有されてないもの全部