svnコマンドから探すgitコマンド


以下で、`<N>`, `<M>` はリビジョン番号 (gitではコミットのハッシュ値)。なお、gitでは、リビジョン番号を書くべき場所でブランチ名を書くとそのHEADのリビジョン番号を書いたのと同じ意味になる (例外あり) 。

ローカルリポジトリに関する操作:

|svnコマンド    |gitコマンド |
|:--------------|:-----------|
|このディレクトリの下だけをcheckout/switch/update/mergeなど                             |基本できない (1.7 からは sparse checkout である程度対応)|
|[`svn export <URL>`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.export.html)     |[`git archive -o <FILE> HEAD`](https://www.kernel.org/pub/software/scm/git/docs/git-archive.html) (zip/tarへ出力) |
|[`svn commit`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.commit.html)           |[`git commit -a`](https://www.kernel.org/pub/software/scm/git/docs/git-commit.html) |
|[`svn add <PATH>`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.add.html)          |[`git add <PATH>`](https://www.kernel.org/pub/software/scm/git/docs/git-add.html) |
|[`svn mkdir <PATH>`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.mkdir.html)      |ディレクトリの下のファイルをadd (空のディレクトリなら、.gitignore などのファイルを作って add) |
|[`svn delete <PATH>`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.delete.html)    |[`git rm <PATH>`](https://www.kernel.org/pub/software/scm/git/docs/git-rm.html)。ブランチ/タグを削除する場合は[`git branch -D <NAME>`](https://www.kernel.org/pub/software/scm/git/docs/git-branch.html)か[`git tag -d <NAME>`](https://www.kernel.org/pub/software/scm/git/docs/git-tag.html)|
|[`svn copy <PATH1> <PATH2>`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.copy.html) |自分でコピーして[`git add <PATH2>`](https://www.kernel.org/pub/software/scm/git/docs/git-add.html)。ブランチ/タグを作る場合は[`git branch <NAME>`](https://www.kernel.org/pub/software/scm/git/docs/git-branch.html)か[`git tag <NAME>`](https://www.kernel.org/pub/software/scm/git/docs/git-tag.html)|
|[`svn move <PATH1> <PATH2>`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.move.html) |[`git mv <PATH1> <PATH2>`](https://www.kernel.org/pub/software/scm/git/docs/git-mv.html)|
|[`svn status`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.status.html)           |[`git status`](https://www.kernel.org/pub/software/scm/git/docs/git-status.html)|
|[`svn log`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.log.html)                 |[`git log`](https://www.kernel.org/pub/software/scm/git/docs/git-log.html)|
|[`svn diff`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.diff.html)               |[`git diff HEAD`](https://www.kernel.org/pub/software/scm/git/docs/git-diff.html) |
|[`svn diff -r <N>`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.diff.html)        |[`git diff <N>`](https://www.kernel.org/pub/software/scm/git/docs/git-diff.html) |
|[`svn diff -r <N>:<M>`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.diff.html)    |[`git diff <N>..<M>`](https://www.kernel.org/pub/software/scm/git/docs/git-diff.html) |
|[`svn patch <FILE>`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.patch.html)      |[`git apply <FILE>`](https://www.kernel.org/pub/software/scm/git/docs/git-apply.html)|
|[`svn merge <URL>[@<N>]`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.merge.html)  |[`git merge <N>`](https://www.kernel.org/pub/software/scm/git/docs/git-merge.html) |
|[`svn merge -c <N>`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.merge.html)      |[`git cherry-pick <N>`](https://www.kernel.org/pub/software/scm/git/docs/git-cherry-pick.html) |
|[`svn merge -c -<N>`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.merge.html)     |[`git revert <N>`](https://www.kernel.org/pub/software/scm/git/docs/git-revert.html)。push前なら、 [`git rebase -i`](https://www.kernel.org/pub/software/scm/git/docs/git-rebase.html)で該当するコミットをskip|
|[`svn resolve <PATH>`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.resolve.html)  |[`git add <PATH>`](https://www.kernel.org/pub/software/scm/git/docs/git-add.html)|
|[`svn revert <PATH>`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.revert.html)    |全体を戻すなら[`git reset --hard HEAD`](https://www.kernel.org/pub/software/scm/git/docs/git-reset.html)。ファイルを選んで戻すなら[`git checkout HEAD <PATH>`](https://www.kernel.org/pub/software/scm/git/docs/git-checkout.html)|
|[`svn switch <URL>[@<N>]`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.switch.html) |他のブランチへ移動するなら[`git checkout <NAME>`](https://www.kernel.org/pub/software/scm/git/docs/git-checkout.html)。古いリビジョンへ移動する場合、無名ブランチを使うなら[`git checkout <N>`](https://www.kernel.org/pub/software/scm/git/docs/git-checkout.html)、現在のブランチのHEADを変えるなら[`git reset --hard <N>`](https://www.kernel.org/pub/software/scm/git/docs/git-reset.html)|

リモートリポジトリに関する操作:

|svnコマンド    |gitコマンド |
|:--------------|:-----------|
|[`svn checkout <URL>`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.checkout.html) |[`git clone <URL>`](https://www.kernel.org/pub/software/scm/git/docs/git-clone.html) して、触りたいブランチを [`git checkout <NAME>`](https://www.kernel.org/pub/software/scm/git/docs/git-checkout.html)|
|[`svn commit`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.commit.html)           |[`git push`](https://www.kernel.org/pub/software/scm/git/docs/git-push.html) |
|[`svn update`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.update.html)           |[`git pull`](https://www.kernel.org/pub/software/scm/git/docs/git-pull.html) (これは [`git fetch`](https://www.kernel.org/pub/software/scm/git/docs/git-fetch.html) して [`git merge`](https://www.kernel.org/pub/software/scm/git/docs/git-merge.html) と同じ)。または [`git pull --rebase`](https://www.kernel.org/pub/software/scm/git/docs/git-pull.html) (これは [`git fetch`](https://www.kernel.org/pub/software/scm/git/docs/git-fetch.html) して [`git rebase`](https://www.kernel.org/pub/software/scm/git/docs/git-rebase.html) と同じ)。|

svnリポジトリに関する操作:

 * 特に初心者は、merge は svn のコマンド (git svn ではなく) で行ったほうが無難 (fast-forward や svn:mergeinfo の問題がある)

|svnコマンド    |gitコマンド |
|:--------------|:-----------|
|[`svn checkout <URL>`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.checkout.html) |[`git-svn clone -r [<N>:]HEAD --preserve-empty-dirs [--stdlayout] <URL>`](https://www.kernel.org/pub/software/scm/git/docs/git-svn.html)|
|[`svn commit`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.commit.html)           |[`git-svn dcommit`](https://www.kernel.org/pub/software/scm/git/docs/git-svn.html) |
|[`svn update`](http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.update.html)           |[`git-svn rebase`](https://www.kernel.org/pub/software/scm/git/docs/git-svn.html)|