LoginSignup
1
1

More than 1 year has passed since last update.

Linux上にリモートリポジトリを作る

Posted at

サーバー側でgit用ユーザアカウントを作成する

[root@node ~]# useradd ユーザ名 /* ユーザ作成 */
[root@node ~]# passwd ユーザ名 /* パスワード設定 */

リモートリポジトリを設定するベースとなるディレクトリを作成する

[root@node ~]# mkdir -pv /opt/git /* ディレクトリ作成 */
[root@node ~]# chown ユーザ名:ユーザ名 /opt/git /* 先ほど作成したユーザに権限付与*/

リモートリポジトリを作成する

[root@node ~]# cd /opt/git /* 作成したディレクトリに移動 */
[root@node ~]# mkdir test.git /* リモートリポジトリを設定するディレクトリを作成 */
[root@node ~]# cd test.git /* 作成したディレクトリに移動 */
[root@node ~]# git --bare --shared init /* リモートリポジトリを設定 */

ローカルリポジトリにリモートリポジトリを追加する

[local@node ~]# git remote add リポジトリ名 ユーザ名@IPアドレス:/opt/git/test.git

ローカルリポジトリからリモートリポジトリにプッシュする

[local@node ~]# git push -u リポジトリ名 リモートリポジトリのブランチ名:ローカルリポジトリのブランチ名

git pushで「error: unpack failed: unpack-objects abnormal exit」エラー!

$ git push
Counting objects: 20, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (15/15), done.
Writing objects: 100% (20/20), 2.77 KiB | 944.00 KiB/s, done.
Total 20 (delta 17), reused 6 (delta 5)
error: remote unpack failed: unpack-objects abnormal exit
To リモートリポジトリ
 ! [remote rejected] ローカルリポジトリのブランチ -> リモートリポジトリのブランチ (n/a (unpacker error))
error: failed to push some refs to 'リモートリポジトリ'

原因

いろいろあるようですが、私の場合はリモートリポジトリの権限エラーでした。

[root@node ~]# chown -R ユーザ名 /opt/git/test.git'

権限付与して無事解決。

参考

ありがとうございました!
http://note.kurodigi.com/linux-gitrepo/
https://nu-pan.hatenablog.com/entry/20140413/1397352725

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1