如何拉取并推送至本地 git 存储库?

如何拉取并推送至本地 git 存储库?

我和同事在 Ubuntu 上一起开发一个项目。他在本地的共享服务器上为我们的项目创建了一个 git 存储库,我们俩都可以访问该存储库。我们不打算将其放在 Github.com 上

我已经克隆了该项目,但我找不到同事如何授予我“贡献者权限”以将其拉到这个本地 git 存储库以及他如何审查我的更改以合并到主分支的方法。

我在网上搜索过,发现唯一的解决方案是将网站放在 Github.com 上,并在网站上授予贡献者权限。

我看到有人说我们应该使用“git init --shared={all|world|everybody}”,但问题仍然存在,我如何才能推送到该存储库,并且他可以在合并之前查看我的更改。我是否应该简单地运行“git push -u origin master”?

我的同事已使用“git init --shared=0777”重新初始化了存储库。但是,当我在“git add . ”和“git commit -m “STH EDITED””之后尝试推送到此存储库时,我收到以下错误:

majid@majid:~/Projects/Annotation$ git push -u /data/sstore-data/projects/AnnotateTool
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:

git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 1.45 KiB | 0 bytes/s, done.
Total 5 (delta 4), reused 0 (delta 0)
remote: error: insufficient permission for adding an object to repository database ./objects
remote: fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit
To /data/sstore-data/projects/AnnotateTool
! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to '/data/sstore-data/projects/AnnotateTool'

答案1

使用一段时间后,这里是基于@PerlDuck 评论的解决方案(谢谢!)以下命令的组合允许与同事或其他小组成员共享服务器上的 git 存储库。

git init --shared={all|world|everybody} git 请求拉取

相关内容