Git bareリポジトリの作成, push,pull

bareリポジトリを主として、cloneして作業リポジトリをつくり pushする。
という流れが基本のようです。

grTestBaseという名前をbareリポジトリの場所として作成

[grTestBase]$ git --bare init
Initialized empty Git repository in /home/jun/git/grTestBase/

grTestBase へ今まで作ったものを push
grtest → grTestBase

[grtest]$ git push /home/jun/git/grTestBase master
Counting objects: 15, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (15/15), 1.21 KiB, done.
Total 15 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (15/15), done.
To /home/jun/git/grTestBase
 * [new branch]      master -> master

今後は、grTestBase をベースとして利用

grTestUseとしてcloneを作成

$ git clone /home/jun/git/grTestBase grTestUse
Cloning into grTestUse...
done.
[git]$ cd grTestUse
[grTestUse]$ ls
test.txt  test2.txt

ちゃんとあります。

別サーバーへもcloneを作成する。sshでログインできる必要がある。
99は今まで利用していたサーバー。別サーバーから以下のようにcloneする。

$ git clone 192.168.99.99:/home/jun/git/grTestBase grTestUse
Cloning into grTestUse...
jun@192.168.99.99's password:
remote: Counting objects: 15, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 15 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (15/15), done.

できました。
別サーバーで変更してcommit & pushしてみます。
text.txtを変更してcommit済みの状態で

$ git push
jun@192.168.99.99's password:
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 331 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To 192.168.99.99:/home/jun/git/grTestBase
   6e2f6c7..3b83010  master -> master

99サーバーのgrTestUseへ最新状態をpullする。

$ git pull
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From /home/jun/git/grTestBase
   6e2f6c7..3b83010  master     -> origin/master
Updating 6e2f6c7..3b83010
Fast-forward
 test.txt |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

別サーバーでの変更が反映されました!

タグをつけてみる

 git tag -a update-first-tag

タグをみる。

$ git tag -l -n
update-first-tag my first tag

This entry was posted on 木曜日, 6月 2nd, 2011 at 8:05 PM and is filed under blog. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。