'VersionCtl/Git/' には、下位層のページがありません。
$ mkdir hoge.git # bare repository 用の空ディレクトリを作成 $ cd hoge.git $ git init --bare --shared=true # bare repository として初期化。管理ファイル群が生成される。共有にするには --shared=true にする
$ cd .. $ git clone hoge # hoge.git から hoge という名前で bare ではないリポジトリとして複製する
$ cd hoge /* 何かしらの方法で新しいファイル fuga を置く */ $ git add fuga # ファイル "fuga" が登録対象になる(まだ登録されていない) $ git commit # 前の git add で指定されたファイルが登録される
--shared=0660のようにする。
$ git checkout -b <local-branch-name> <remote-repository>/<remote-branch-name>
$ git checkout work1
$ git checkout work1 Switched to branch 'work1'
$ git checkout -b <new-local-branch-name> refs/tags/<tag-name>
$ git clone [options...] <repository> [<directory>]
option | description |
---|---|
--recursive | リポジトリ内に含まれる submodule も同時に複製する。 |
--bare | bare repository として clone する |
-o (--origin) <origin-repository> | 複製先で使用する、複製元のリポジトリ名を <oritin-repository> として指定する 指定しなかった場合は "origin" が使われる |
-b (--branch) <branch-name> | 複製先の HEAD が指すブランチの名前を <branch-name> で指定する。 指定しない場合は、複製元の HEAD が指すブランチが使われれる。 |
--morror | ミラーリポジトリとして複製元リポジトリを複製する。 複製元リポジトリ自体もミラーリポジトリだった場合は、その追跡ブランチなどの参照情報も、複製元から完全にコピーされる。 |
$ git branch * work
$ git branch -m <元の名前> <新しい名前>
$ git checkout work1 Switched to branch 'work1'
$ git branch -d work1
$ git add <変更を加えたファイル> $ git commit
(1)再度 commit する。履歴は全て別々に残る (2)commit をやり直す。履歴は別々にしない。の2つの選択肢がある。やり直しの対象となる commit のログを残したくない場合、やり直し時に "--amend" オプションをつけることで実現できる。
$ git add hoge $ git commit --amend
$ git push <反映先> <反映元>
option | description |
---|---|
-u, --set-upstream | 新規に作成したリポジトリやブランチを push する際に、ローカルリポジトリと push 先のリポジトリとのブランチ対応付けを行う。 対応付けを行うことにより、次回以降 push 時にブランチ名を省略できる。 |
--all | ブランチを全て push する |
--tags | 全ての tag を push する(*) |
--mirror | リモートリポジトリに、ローカルリポジトリの内容をそのまま複製したいときに使用する。ローカルで削除されたブランチはリモートでも削除される |
--delete <repository> <branch-to-be-deleted> | リモートリポジトリのブランチを削除する |
<repository> :<branch-to-be-deleted> | |
-n, --dry-run | 変更情報の送信とリモートリポジトリへの反映結果を確認する。実際にはリモートリポジトリへの反映は行われない |
-f, --force | リモートブランチがローカルブランチの派生元でない場合でも、強制的に上書きする。 リモートブランチのコミット情報を失う場合があるので、注意が必要 |
--progress | 標準エラーに進捗状況を出力する |
<repository> | push 対象となるリポジトリを指定する。リモート名または URI を指定する |
<refspec> | <src>:<dst> のフォーマットで送信元:送信先ブランチを指定する。例えば、branch-a から branch-b に push する場合、次のように指定する: branch-a:branch-b |
$ git push <dst-branch> <local-tag-name>:<remote-tag-name>
$ git push <src-branch-name>:<dst-branch-name>
$ git push <remote-repository> <local-new-branch-name>
$ git config --add branch.<local-branch-name>.remote <remote-name> $ git config --add branch.<local-branch-name>.merge <remote-branch-name> $ git push -u <remote-branch-name> <local-branch-name>
$ git push -f <repository> HEAD^:<branch-name-to-be-pushed>
$ git push -f origin HEAD^:xemacs Total 0 (delta 0), reused 0 (delta 0) remote: error: denying non-fast-forward refs/heads/xemacs (you should pull first) To /home/kazu/git_repos/emacs/xemacs.git/ ! [remote rejected] HEAD^ -> xemacs (non-fast-forward) error: failed to push some refs to '/home/kazu/git_repos/emacs/xemacs.git/'
vi <bare-repository>/config [core] repositoryformatversion = 0 filemode = true bare = true sharedrepository = 1 [receive] denyNonFastforwards = true # ←これを false にする
$ ls -l .git/ 合計 60 -rw-r--r-- 1 user1 user1 24 11月 22 18:13 COMMIT_EDITMSG -rw-r--r-- 1 user1 user1 293 10月 10 14:19 FETCH_HEAD -rw-r--r-- 1 user1 user1 48 10月 28 02:13 GITGUI_MSG -rw-r--r-- 1 user1 user1 23 5月 4 2015 HEAD -rw-r--r-- 1 user1 user1 41 10月 10 14:19 ORIG_HEAD drwxr-xr-x 2 user1 user1 6 5月 4 2015 branches -rw-r--r-- 1 user1 user1 315 10月 28 02:14 config -rw-r--r-- 1 user1 user1 73 5月 4 2015 description drwxr-xr-x 2 user1 user1 4096 5月 4 2015 hooks -rw-r--r-- 1 user1 user1 19357 11月 22 18:12 index drwxr-xr-x 2 user1 user1 20 5月 4 2015 info drwxr-xr-x 3 user1 user1 28 5月 4 2015 logs drwxr-xr-x 186 user1 user1 4096 9月 20 19:08 objects drwxr-xr-x 5 user1 user1 43 5月 4 2015 refs
name | description |
---|---|
HEAD | 現在チェックアウトされているブランチ(HEAD)がどういう参照情報かが書かれている |
config | この git リポジトリの設定内容 |
description | この git リポジトリの説明が記述される。 GitWeb でリポジトリを HTTP 公開したり、メールでコミットメッセージを送信するときなどに利用される。 |
hooks/ | このディレクトリ配下にフックスクリプトを配置する |
info/ | この git リポジトリで無視したいファイルを info/exclude に記述する |
objects/ | この git リポジトリで管理する git オブジェクトの実体がここに配置される |
refs/ | ブランチやタグが指す git オブジェクトがどれかという参照情報がここに置かれる |
$ git log commit bdf1da8aecdfbe5a83ce93e78e2ad8a241b1530b Author: hogehoge <hogehoge@fuga.com> Date: Mon May 4 13:33:13 2015 +0900 fix build break for System commit 1072326e20c9dd482d5e1db46419b0412317d693 Author: hogehoge <hogehoge@fuga.com> Date: Mon May 4 13:12:33 2015 +0900 delete Makefile.bak ...
$ git revert bdf1da8aecdfbe5a83ce93e78e2ad8a241b1530b
$ git reset [commit-ID]
$ git reset --hard AAAA^ # AAAA の1個前の commit まで戻る※コミット自体を取り消す場合には、少なくとも対象のより1個前の commit まで履歴を戻るのがポイント。
$ git merge <反映先 branch>
option | description | remark |
---|---|---|
--no-ff | Fast-forward merge を強制的に抑止し、merge commit が必ず発生するようにする。 | |
--squash <branch> | <branch> に commit されている複数のcommit を1つに纏める。 | merge commit は自動生成されないので、 git commit を手動で行う必要がある。 merge に際して committer や log を改変する必要がある場合にも使える |
$ git tag <tag-name>
$ git tag <tag-name> <commit-ID>
$ git push --tags # 全ての tag 情報を push する
$ git push <tag-to-be-pushed>
$ git tag -d <tag-name>
$ git push <remote-repository> :<tag-name-to-be-deleted>
/ .
ASCII制御文字 SPACE ~ | ^ : ? * [ \ DEL文字(\177)
.. .lock @{
$ git diff
$ git clean [-n]
$ git status
$ git pull --rebase
$ git pull --rebase
$ git rebase --continue
$ git rebase --abort
$ git pull remote: Counting objects: 5, done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. From /home/kazu/work/git_test/a 1413a9c..ac702ad master -> origin/master Auto-merging 1.txt CONFLICT (content): Merge conflict in 1.txt Automatic merge failed; fix conflicts and then commit the result.
AAAAA <<<<<<< HEAD BBBBBBBBB CCCCCCCCCCCCCCCCCCCCCCC DDDD EEEEEEEEEEEEE ======= 111111111111111111 22222222222 33333333333333333333 4444444 >>>>>>> ac702ad3f09388ac676c926b7a03c2a97a77f94f
<<<<<<< HEAD (手元での修正) ======= (<commit-name> によって変更された修正) >>>>>>> <commit-name>
$ git add <file-name> $ git commitここで conflict を解消した旨のコメントが予め用意された log 記入画面が表示される:
Merge branch 'master' of /path/repos-dir Conflicts: 1.txt # # It looks like you may be committing a merge. # If this is not correct, please remove the file # .git/MERGE_HEAD # and try again. ...
$ git checkout <selection> <file-name>
selection | description | remark |
---|---|---|
MERGE_HEAD | merge する branch の HEAD | |
ORIG_HEAD | 現在の branch の HEAD |
commit 772a23b56ce10fd0b986d84a265ed25d5723cee8 Author: user-name <hoge@example.com> Date: Sun Jul 5 12:16:20 2015 +0900 [mod] disc.shtml: modify link URI
commit 772a23b56ce10fd0b986d84a265ed25d5723cee8 Author: user-name <hoge@example.com> Date: Sun Jul 5 12:16:20 2015 +0900 [mod] disc.shtml: modify link URI disc.shtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
commit 772a23b56ce10fd0b986d84a265ed25d5723cee8 Author: user-name <hoge@example.com> Date: Sun Jul 5 12:16:20 2015 +0900 [mod] disc.shtml: modify link URI M disc.shtml
commit 772a23b56ce10fd0b986d84a265ed25d5723cee8 Author: user-name <hoge@example.com> Date: Sun Jul 5 12:16:20 2015 +0900 [mod] disc.shtml: modify link URI 1 1 disc.shtml
commit 772a23b56ce10fd0b986d84a265ed25d5723cee8 Author: user-name <hoge@example.com> Date: Sun Jul 5 12:16:20 2015 +0900 [mod] disc.shtml: modify link URI disc.shtml
$ git reflog fff7841 HEAD@{9}: pull: Merge made by the 'recursive' strategy. 9fdb195 HEAD@{10}: commit: Modify Link URI e56109d HEAD@{11}: reset: moving to HEAD^ d5df2c7 HEAD@{12}: reset: moving to d5df2c7858f198496fca335d22dec36a50bb91b0 69ab6a1 HEAD@{13}: pull: Fast-forward d5df2c7 HEAD@{14}: reset: moving to d5df2c7858f198496fca335d22dec36a50bb91b0 69ab6a1 HEAD@{15}: pull: Fast-forward d5df2c7 HEAD@{16}: reset: moving to d5df2c7858f198496fca335d22dec36a50bb91b0 69ab6a1 HEAD@{17}: commit: 再修正 d5df2c7 HEAD@{18}: commit: リンク集 URI 修正
$ git log commit 47aea4296981269c1f3e4a779602ec0f649cfe5f Author: hoge <hoge@localhost> Date: Sat Dec 24 00:28:19 2016 +0900 Modify email page - input type of email-form (input type="email"). - visual in confirm page. commit fe4cdb4c96822ab2ea5418b0627795b5bd6f83ce Author: hoge <hoge@localhost> Date: Fri Dec 23 15:54:32 2016 +0900 Modify comment. commit be940a58ff8b33e33e8211b390f4538a06b1803c Author: hoge <hoge@localhost> Date: Fri Dec 23 15:51:12 2016 +0900 Modify Design, remove unnesessary CSS definition. commit 85af578464c613ade32420a25c267dd2f77a31c4 Author: hoge <hoge@localhost> Date: Thu Dec 22 01:08:21 2016 +0900 Modify design.
$ git reset --hard HEAD^^ $ git log commit be940a58ff8b33e33e8211b390f4538a06b1803c Author: hoge <hoge@localhost> Date: Fri Dec 23 15:51:12 2016 +0900 Modify Design, remove unnesessary CSS definition. commit 85af578464c613ade32420a25c267dd2f77a31c4 Author: hoge <hoge@localhost> Date: Thu Dec 22 01:08:21 2016 +0900 Modify design.
$ git reflog be940a5 HEAD@{0}: reset: moving to HEAD^^ 47aea42 HEAD@{1}: reset: moving to 47aea42 dc324eb HEAD@{2}: checkout: moving from 057c6eb522986eb442cfcb5a968c8467271af319 to dc324eb8481e1b0f9dd3f1ffc1b19177653bec4b 057c6eb HEAD@{3}: checkout: moving from 49e4a499eb67f0eac4898241c52a6b7287d35d86 to 057c6eb522986eb442cfcb5a968c8467271af319 49e4a49 HEAD@{4}: checkout: moving from ba052fa7aaf00cd0186cfb6b367d909f7f0f773b to 49e4a499eb67f0eac4898241c52a6b7287d35d86 ba052fa HEAD@{5}: checkout: moving from 85af578464c613ade32420a25c267dd2f77a31c4 to ba052fa7aaf00cd0186cfb6b367d909f7f0f773b 85af578 HEAD@{6}: checkout: moving from master to 85af578464c613ade32420a25c267dd2f77a31c4 47aea42 HEAD@{7}: commit: Modify email page fe4cdb4 HEAD@{8}: commit: Modify comment. be940a5 HEAD@{9}: commit: Modify Design, remove unnesessary CSS definition. 85af578 HEAD@{10}: commit: Modify design.
47aea42 HEAD@{7}: commit: Modify email page
$ git reset --hard 47aea42
$ git log commit 47aea4296981269c1f3e4a779602ec0f649cfe5f Author: hoge <hoge@localhost> Date: Sat Dec 24 00:28:19 2016 +0900 Modify email page - input type of email-form (input type="email"). - visual in confirm page. commit fe4cdb4c96822ab2ea5418b0627795b5bd6f83ce Author: hoge <hoge@localhost> Date: Fri Dec 23 15:54:32 2016 +0900 Modify comment. commit be940a58ff8b33e33e8211b390f4538a06b1803c Author: hoge <hoge@localhost> Date: Fri Dec 23 15:51:12 2016 +0900 Modify Design, remove unnesessary CSS definition. commit 85af578464c613ade32420a25c267dd2f77a31c4 Author: hoge <hoge@localhost> Date: Thu Dec 22 01:08:21 2016 +0900 Modify design.
<commit-ID> <属するrepositorまたはtag>~<HEADから数えて幾つ前か>
$ git name-rev d827bb3b0304ec0abead4d44a3601c6a65417fde d827bb3b0304ec0abead4d44a3601c6a65417fde remotes/origin/np/extract-change~1
$ git blame <file-name>
75d29a26 dash.el (Magnar Sveen 2014-12-02 07:06:35 +0100 423) `(-iterate (lambda (it) ,form) ,init ,n)) 75d29a26 dash.el (Magnar Sveen 2014-12-02 07:06:35 +0100 424) f780322b dash.el (Matus Goljer 2014-05-03 17:22:03 +0200 425) (defun -flatten-n (num list) c6b92ae2 dash.el (Matus Goljer 2014-06-04 18:05:25 +0200 426) "Flatten NUM levels of a nested LIST. c6b92ae2 dash.el (Matus Goljer 2014-06-04 18:05:25 +0200 427) c6b92ae2 dash.el (Matus Goljer 2014-06-04 18:05:25 +0200 428) See also: `-flatten'" f780322b dash.el (Matus Goljer 2014-05-03 17:22:03 +0200 429) (-last-item (--iterate (--mapcat (-list it) it) list (1+ num)))) f780322b dash.el (Matus Goljer 2014-05-03 17:22:03 +0200 430) f1c84533 dash.el (Magnar Sveen 2012-10-22 15:42:15 +0200 431) (defun -concat (&rest lists) c6b92ae2 dash.el (Matus Goljer 2014-06-04 18:05:25 +0200 432) "Return a new list with the concatenation of the elements in the supplied LISTS." 38028904 bang.el (Magnar Sveen 2012-10-22 15:26:40 +0200 433) (apply 'append lists)) ^302c8ea bang.el (Magnar Sveen 2012-09-24 21:02:58 +0200 434) 25c114c5 dash.el (Wilfred Hughes 2014-06-26 23:44:05 +0100 435) (defalias '-copy 'copy-sequence 25c114c5 dash.el (Wilfred Hughes 2014-06-26 23:44:05 +0100 436) "Create a shallow copy of LIST.") 25c114c5 dash.el (Wilfred Hughes 2014-06-26 23:44:05 +0100 437) 174747ea dash.el (Matus Goljer 2014-06-04 17:26:41 +0200 438) (defun -splice (pred fun list) 174747ea dash.el (Matus Goljer 2014-06-04 17:26:41 +0200 439) "Splice lists generated by FUN in place of elements matching PRED in LIST. 174747ea dash.el (Matus Goljer 2014-06-04 17:26:41 +0200 440)
$ git stash
$ git stash list
$ git stash pop
$ git stash apply
$ git stash drop
$ git rebase A2 branch_Y
== A0 ==== A1 ==== A2 ===== A3 ==== A4 ===== --- branch_X | +== B1 == B2 == B3 == B4 === --- branch_Y ↓ == A0 ==== A1 ==== A2 ===== A3 ==== A4 ===== --- branch_X | +== B1 == B2 == B3 == B4 = --- branch_Y
$ git rebase branch_X branch_Y
== A0 ==== A1 ==== A2 ===== A3 ==== A4 ===== --- branch_X | +== B1 == B2 == B3 == B4 === --- branch_Y ↓ == A0 ==== A1 ==== A2 ===== A3 ==== A4 ===== --- branch_X | +== B1 == B2 == B3 == B4 = --- branch_Y
$ git rebase --onto branch_X branch_Y branch_Z
== A0 ==== A1 ==== A2 ===== A3 ==== A4 ===== --- branch_X | +== B1 == B2 == B3 == B4 === --- branch_Y | +=== C1 ==== C2==== --- branch_Z ↓ == A0 ==== A1 ==== A2 ===== A3 ==== A4 ===== --- branch_X | +== B1 == B2 == B3 == B4 === --- branch_Y | +=== C1 ==== C2==== --- branch_Z
$ git rebase --continue | --skip | --abort
option | description |
---|---|
--continue | 競合解決中に、 rebase を再開したい場合に指定する |
--skip | 競合解決中に、 その commit を skip したいときに指定する。skip した commit は適用されない |
--abort | 競合解決中に、rebase を中止し、 rebase 開始前の状態に戻りたい場合に指定する |
$ git remote add [-t <branch>] [-f] [--tags|--no-tags] [--mirror] <remote-repos-name> <url>
option | description | remark |
---|---|---|
-t <branch> | pull で更新内容を取得するリモートブランチを限定出来る。 | ブランチは複数指定可能 |
-f | リモートを設定した後、リモートリポジトリから fetch する | |
--tags | --no-tags | remote コマンドでは、デフォルトではリモートブランチのHEAD から参照出来る tag のみ取得する。 このオプションが指定されると、tag を取得しない。 | |
--mirror | リモートリポジトリがベアリポジトリの場合、push 実行時にローカルリポジトリの内容を常にリモートリポジトリに複製するようになる。 | バックアップ用途、他のサーバにリポジトリのコピーを置きたい場合に使用する。 |
rm <remote-repos-name> | リモート名 <name> の設定とローカルリポジトリに取得されたリモートブランチ(リモート追跡ブランチ)を削除する |
$ git remote -v origin /home/hoge/work/hoge-repository.git (fetch) origin /home/hoge/work/hoge-repository.git (push)
$ git remote rm <remote-repos-name>
$ git remote prune [-n] <remote-repos-name>
$ git remote <old> <new>
$ git remote set-url [--push] <remote-repos-name> <new-url> [old-url]
$ git bundle create <file> <git-rev-list-args>
$ git bundle create <file> hoge-tag..fuga
category | git-rev-list-args | description | remark |
---|---|---|---|
limiting output | --max-count=<n> | ||
--max-age=<epoch> | |||
--min-age=<epoch> | |||
--sparse | |||
--no-merges | |||
--min-parents=<n> | |||
--no-min-parents | |||
--max-parents=<n> | |||
--no-max-parents | |||
--remove-empty | |||
--all | 全ての commit を含める | ||
--branches | |||
--tags | |||
--remotes | |||
--stdin | |||
--quiet | |||
ordering output | --topo-order | ||
--date-order | |||
--reverse | |||
formatting output | --parents | ||
--children | |||
--objects | |||
--objects-edge | |||
--unpacked | |||
--header | |||
--pretty | |||
--abbrev=<n> | |||
--no-abbrev | |||
--abbrev-commit | |||
--left-right | |||
special purpose | --bisect | ||
--bisect-vars | |||
--bisect-all |
$ git bundle verify <file> [refname]
$ git bundle list-heads <file> [<refname>...]
$ ls hoge.bundle $ git clone hoge bundle hoge Cloning into 'hoge'... Receiving objects: 100% (1616/1616), 15.62 MiB | 0 bytes/s, done. Resolving deltas: 100% (629/629), done. Checking connectivity... done. warning: remote HEAD refers to nonexistent ref, unable to checkout.
$ cd hoge $ls -a . .. .git
$ git checkout master Branch master set up to track remote branch master from origin. Already on 'master' $ ls archive chat index.shtml menu.html pukiwiki-plugins wiki bbs img linux.css menu.shtml test
== A0 ==== A1 ==== A2 ===== A3 ==== A4 ===== --- remote branch | +== B1 == B2 : local repository に commit された変更(local の HEAD が A0から分岐したB2になった状態) ↓ git pull --rebase ↓ == A0 ==== A1 ==== A2 ===== A3 ==== A4 ===== --- remote branch | +== B1 == B2 : local repository に commit された変更(local の HEAD が A4から分岐したB2になった状態)
$ git rebase --continue
$ git rebase --abort
$ git pull <refspec>
foo: http://foobar.com/foo.git # aa.txt が commit されている bar: http://foobar.com/bar.git # ps-ax.log が commit されている
$ git clone http://foobar.com/foo.git
$ cd foo $ git submodule add http://foobar.com/bar.git baz # ここでディレクトリ foo/baz が作成される Cloning into 'baz'... done. $ ls -a . .. .git .gitmodules aa.txt baz # .gitmodules と baz が追加された # ここで、baz が初期化される場合とされない場合がある。 # git submodule とtype したときに表示される hash に "-" がついていれば、 baz は初期化されていない。 # この場合は次のように手動で初期化する必要がある
$ git submodule init baz Submodule 'baz' (http://foobar.com/bar.git) registered for path 'baz' $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: .gitmodules # new file: baz #
$ git commit $ git push
$ git clone http://foobar.com/foo.git new-foo $ cd new-foo $ ls aa.txt baz # 先ほど追加し、 commmit & push した baz が出来ている $ ls -a baz . .. # 単にからディレクトリが出来ただけ。 $ git submodule -386b630fd974b3f3147d462cda2c1f50813131fc baz # hash に "-" が付いており、初期化されていないことが分かる
$ git submodule init baz Submodule 'baz' (http://foobar.com/bar.git) registered for path 'baz' $ ls -a baz . .. # この段階でも、まだ baz は空ディレクトリのままになっている
$ git submodule update Cloning into 'baz'... done. Submodule path 'baz': checked out '386b630fd974b3f3147d462cda2c1f50813131fc' $ ls -a baz/ . .. .git ps-ax.log # bar.git の中身が baz に clone される
$ git diff --no-prefixとする必要がある。
$ git diff -b <file>
$ git config --global user.name "UserName" $ git config --global user.email "account@example.com"
$ git config --global alias.ci "commit" # "git commit" を "git ci" でも実行できるようにする $ git config --global alias.co checkout $ git config --global alias.st status $ git config --global alias.br branch $ git config --global alias.bl blame $ git config --global alias.logs "log --name-status" $ git config --global alias.fe fetch $ git config --global alias.nr name-rev
$ git config --global core.pager ''
configuration item | description | remark |
---|---|---|
user.name | ユーザ名を指定する | |
user.email | ユーザのメールアドレスを指定する | |
receive.denyNonFastFowards | true に設定すると、 push 時に repository 上の commit が含まれない commit を送信しようとしたときに branch の更新を拒否する | shared repository で設定する |
receive.denyDeletes | true に設定すると、ブランチの削除を拒否する | shared repository で設定する |
receive.fsckObjects | true にすると、push されたときにデータ一貫性のチェックを行う。信頼性が向上するが、 push 処理に時間が掛かるようになる。 | shared repository で設定する |
core.pager | pager を指定する | 例えばless, lv など |
alias.<alias-name> | 任意の git コマンド(commit, checkoutなど)を <alias-name> でも呼び出せるようにする |
$ git config <--local|--global|--system> <-e|--edit>
$ git config <-l|--list>
config | description |
---|---|
hooks.mailinglist | push された時にコミットメッセージを送信する ML |
hooks.announcelist | git tag <tag-name> -m <message> でタグを生成した時に通知される ML |
hooks.emailprefix | メールの Subject: の先頭につける文字列。 デフォルトは [SCM] |
hooks.envelopesender | メールの From: に記載される送信者アドレス |
hooks.showrev | メールに添付するメッセージを生成するコマンド。デフォルトでは git revlist --pretty --stdin $revspec 差分情報を送るには、 git config hooks.showrev "git show -C \$t; scho" とする |
$ git config hooks.mailinglist hoge-ml@example.com $ git config hooks.announcelist announce-ml@example.com $ git config hooks.emailprefix "[GIT]" $ git config hooks.envelopesender "git-admin@example.com"
$ git config [--local|--global|--system] --unset <key>
$ git config [--local|--global|--system] --unset-all
option | description |
---|---|
--aggressive | 最適化の度合いを大きくする。 処理時間がかかるが、その分最適化された状態にする。 |
--prune=<date> | <date> で指定されたものより古いオブジェクトを破棄する。 右辺に何も指定しなかった場合のデフォルト値は "2 weeks ago" となる。 また、右辺に "now" を指定すると、全ての不要なオブジェクトが削除される。 |
*.bak *.o tmp
$ git add .gitignore $ git ci -m "[add] .gitignore" $ git push
$ git filter-branch --tree-filter 'git rm --ignore-unmatch <file-to-be-deleted>' --prune-empty -- --all
$ git filter-branch --tree-filter 'git rm --cached --ignore-unmatch "*.o"' --prune-empty -- --all
$ git reflog expire --expire=now --all $ git gc --prune=now $ git gc --aggressive --prune=now
<src>:<dst>の書式による、ブランチ指定のこと。
Git | Subversion | Description |
---|---|---|
git init | svnadmin create | リポジトリ作成 |
git clone | svn checkout | リポジトリのコピー |
git add <file> | svn add <file> | ファイルの追加 |
git add <file>; git commit | svn commit [file] | ファイルの更新をリポジトリに反映 |
git rm <file> | svn rm <file> | ファイルの削除(別途、要 commit) |
git status | svn status | |
git log [file] | svn log [file] | ログを表示する |
git log --shortstat --name-status | svn log -v | 追加・変更されたファイル名を含めたログを表示する |
git log -<number> | svn log -l <number> | 最新から <number> 個のログエントリを表示する |
git blame <file> | svn blame <file> | <file> の各行がいつ誰によって変更されたかを表示する |
git checkout <branch> | svn switch <branch> | |
git merge <branch> | svn merge <branch> | |
git checkout <file> | svn revert <file> | ファイルに対して行った(リポジトリに未反映の)変更を元に戻す |
git clean -f | svn revert [dir] | |
git pull <remote> <local> | svn up[date] | <remote> の最新状態を <local> に merge する |
$ gitk
$ git gui
$ git init --bare --shared=true repos.git
$ vi authors.txt hoge = hoge <hoge@your-domain.com> fuga = fuga <foo@example.com>
$ git svn clone -A authors.txt --trunk= --branches=branches --prefix=svn/ ${SVN_REPOS_URL}
file://<絶対パス> http://... https://... ssh://... ssh+svn://...
$ git remote add origin ../repos.git $ git push origin --all