git - 在 Ubuntu 上设置本地 git 存储库

标签 git ubuntu

我正在尝试在我的本地机器上设置一个 Git 存储库,用于在我的本地机器上完成的工作 - 没有远程任何东西。

我已经多次设置远程存储库,但似乎我在本地采取的步骤总是以错误告终。

我有 2 个目录:/home/rico/project/home/git/project_repo
我创建了 git 用户来管理我所有的 git 存储库(我希望有几十个)。

来自 /home/rico/project作为 rico用户我执行以下命令:

rico@verbal:~/project$ git init
Initialized empty Git repository in /home/rico/project/.git/

来自 /home/git/project_repo作为 git用户我执行以下操作:
git@verbal:~/project_repo$ git --bare init
Initialized empty Git repository in /home/git/project_repo

现在我回到我的项目并添加文件。
rico@verbal:~/project$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       .project
#       .pydevproject
#       inc/
#       manage.py
#       rocksolidbox/
#       rsb/
#       templates/
rico@verbal:~/project$ git add inc media rocksolidbox/ rsb/ templates/
rico@verbal:~/project$ git commit -a -m "Initialize the project."

此时我收到了正常的提交消息 - 23 files changed, 989 insertions(+)等等

现在,我想将此推送到 project_repo文件夹。
rico@verbal:~/project$ git remote add origin /home/git/rocksolidbox/
rico@verbal:~/project$ git push -u /home/git/rocksolidbox/ master

但收到以下错误:
Counting objects: 31, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (26/26), done.
error: insufficient permission for adding an object to repository database ./objects

fatal: failed to write object
Writing objects: 100% (31/31), 12.24 KiB, done.
Total 31 (delta 2), reused 0 (delta 0)
error: unpack failed: unpack-objects abnormal exit
To /home/git/project_repo/
 ! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to '/home/git/project_repo/'

显然这是一个权限错误。我试图做这样的 push :
rico@verbal:~/project$ git push -u git@verbal:/home/git/rocksolidbox/ master

甚至使用我的本地 IP:
rico@verbal:~/project$ git push -u git@192.168.1.101:/home/git/rocksolidbox/ master

它要求输入密码,我知道我提供的密码正确,并且我不断收到消息 Permission denied, please try again.
我只想能够推送我的project给我的project_repo .我在这个设置中做错了什么?

最佳答案

不要做所有花哨的权限步法。你想要gitolite .

关于git - 在 Ubuntu 上设置本地 git 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12884769/

相关文章:

git - 将 git 存储库移动到 nfs 会导致权限错误

git pull master 出现错误 : fatal: couldn't find remote ref master

git - 如何在 Android Studio 中 check out 旧的 git 提交?

git - 从技术角度看 git index 到底是什么

git:我不想提交的许多本地更改

ruby-on-rails - Slicehost 上的 Ubuntu 8.10 监控软件?

git - Visual Studio 代码 : Push to git works from Terminal but not when using the user interface

ruby-on-rails - 如何启动 rails server localhost :3000 on ubuntu 12. 04

laravel php artisan serve 命令有效,但 localhost url 在 ubuntu 18.10 中不起作用

ubuntu - 重启 Upstart 实例进程