git_push
git push
git-push (git push) は git のサブコマンド。
説明を読む:
$ git-push -h
usage: git-push [--all | --mirror] [--dry-run] [--tags]
[--receive-pack=<git-receive-pack>] [--repo=all]
[-f | --force] [-v] [<repository> <refspec>...]
-v, --verbose be verbose
--repo <repository> repository
--all push all refs
--mirror mirror all refs
--tags push tags
--dry-run dry run
-f, --force force updates
--thin use thin pack
--receive-pack <receive-pack>
receive pack program
--exec <receive-pack>
receive pack program
git-push を使ってリポジトリと作業ファイルを別のマシン(remote-pc)にコピーする:
- 前提: local-pc から remote-pc に ssh できるが、逆はできない。
- 方針: remote-pc に空の git 作業ディレクトリを作り、そこに local-pc から ssh で(masterブランチを)git-push する。remote-pc では .git の中身だけが更新されるので、git checkout する。
[remote-pc にて] $ cd /data $ mkdir work-dir $ cd work-dir $ git init [local-pc にて] $ git push nishi@remote-pc:/data/work-dir master nishi@remote-pc's password: Counting objects: 27, done. Compressing objects: 100% (24/24), done. Writing objects: 100% (27/27), 7.67 KiB, done. Total 27 (delta 9), reused 0 (delta 0) To nishi@remote-pc:/data/work-dir * [new branch] master -> master [remote-pc にて] $ cd /data/work-dir $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # deleted: main.rb # deleted: rakefile.rb # deleted: subtask.rb # $ git checkout $ ls main.rb rakefile.rb subtask.rb
remote-pc での作業を local-pc に戻すには git_pull を参照。
リポジトリを ssh 経由で複製する
リモートで準備:
$ cd $ mkdir app $ cd app $ git init
ローカルから push する:
$ cd app $ git push ssh://remote/~user/app master
github に直接 push する例:
$ git push git@github.com:nishimotz/libopenjtalk.git master
git_push.txt · 最終更新: 2012/02/17 21:53 by Takuya Nishimoto
