通过 ssh 在私有服务器上实现类似 github 的工作流程

发布于 2024-08-30 10:53:25 字数 2301 浏览 3 评论 0原文

我在互联网上有一个服务器(可通过 ssh 访问),我和我的朋友用它来一起处理项目。我们已经开始使用 git 进行源代码控制。目前我们的设置如下:

  • 朋友在 server 上使用 git --bare init 创建了名为 project.friend.git 的存储库,
  • 我克隆了 server 上的 project.friend.gitproject.jesse.git
  • 然后我在 上克隆了 project.jesse.git使用 git clone jesse@server:/git_repos/project.jesse.git 将服务器连接到我的本地计算机
  • 我在本地计算机上工作并提交到本地计算机。当我想将更改推送到 server 上的 project.jesse.git 时,我使用 git Push origin master。我的朋友正在开发 project.friend.git。当我想获取他的更改时,我会 pull jesse@server:/git_repos/project.friend.git

一切似乎都工作正常,但是,当我执行 git push origin master 时,我现在收到以下错误:

localpc:project.jesse jesse$ git push origin master
Counting objects: 100, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (76/76), done.
Writing objects: 100% (76/76), 15.98 KiB, done.
Total 76 (delta 50), reused 0 (delta 0)
warning: updating the current branch
warning: Updating the currently checked out branch may cause confusion,
warning: as the index and work tree do not reflect changes that are in HEAD.
warning: As a result, you may see the changes you just pushed into it
warning: reverted when you run 'git diff' over there, and you may want
warning: to run 'git reset --hard' before starting to work to recover.
warning: 
warning: You can set 'receive.denyCurrentBranch' configuration variable to
warning: 'refuse' in the remote repository to forbid pushing into its
warning: current branch.
warning: To allow pushing into the current branch, you can set it to 'ignore';
warning: but this is not recommended unless you arranged to update its work
warning: tree to match what you pushed in some other way.
warning: 
warning: To squelch this message, you can set it to 'warn'.
warning: 
warning: Note that the default will change in a future version of git
warning: to refuse updating the current branch unless you have the
warning: configuration variable set to either 'ignore' or 'warn'.
To jesse@server:/git_repos/project.jesse.git
   c455cb7..e9ec677  master -> master

此警告是我需要担心的吗?就像我说的,一切似乎都很顺利。我的朋友能够从我的分支中提取我的更改。我在服务器上有克隆,因此他可以访问它,因为他无权访问我的本地计算机。有什么可以做得更好的吗?

谢谢!

I have an server (available via ssh) on the internet that my friend and I use for working on projects together. We have started using git for source control. Our setup currently is as follows:

  • Friend created repository on server with git --bare init named project.friend.git
  • I cloned project.friend.git on server to project.jesse.git
  • I then cloned project.jesse.git on server to my local machine using git clone jesse@server:/git_repos/project.jesse.git
  • I work on my local machine and commit to the local machine. When I want to push my changes to the project.jesse.git on server I use git push origin master. My friend is working on project.friend.git. When I want to get his changes I do pull jesse@server:/git_repos/project.friend.git.

Everything seems to be working fine, however, I am now getting the following error when I do git push origin master:

localpc:project.jesse jesse$ git push origin master
Counting objects: 100, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (76/76), done.
Writing objects: 100% (76/76), 15.98 KiB, done.
Total 76 (delta 50), reused 0 (delta 0)
warning: updating the current branch
warning: Updating the currently checked out branch may cause confusion,
warning: as the index and work tree do not reflect changes that are in HEAD.
warning: As a result, you may see the changes you just pushed into it
warning: reverted when you run 'git diff' over there, and you may want
warning: to run 'git reset --hard' before starting to work to recover.
warning: 
warning: You can set 'receive.denyCurrentBranch' configuration variable to
warning: 'refuse' in the remote repository to forbid pushing into its
warning: current branch.
warning: To allow pushing into the current branch, you can set it to 'ignore';
warning: but this is not recommended unless you arranged to update its work
warning: tree to match what you pushed in some other way.
warning: 
warning: To squelch this message, you can set it to 'warn'.
warning: 
warning: Note that the default will change in a future version of git
warning: to refuse updating the current branch unless you have the
warning: configuration variable set to either 'ignore' or 'warn'.
To jesse@server:/git_repos/project.jesse.git
   c455cb7..e9ec677  master -> master

Is this warning anything I need to be worried about? Like I said, everything seems to be working. My friend is able to pull my changes in from my branch. I have the clone on the server so he can access it since he does not have access to my local machine. Is there something that could be done better?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青春有你 2024-09-06 10:53:25

您应该在服务器上设置一个存储库。裸存储库仅包含版本历史信息,该信息通常位于存储库根目录的 .git 目录中。您可以从它克隆或推送到它,就像使用任何其他存储库一样。

裸存储库是使用创建的

 git init --bare

如果您已经有一些版本历史记录,请进行裸克隆

git clone --bare git://some/where

至于您的警告,请参阅 这个问题

You should set up a bare repository on the server. A bare repository contains only the version history information that is usually in the .git directory in your repository root. You can clone from it or push to it like with any other repository.

Bare repositories are created with

 git init --bare

If you already have some version history make a bare clone

git clone --bare git://some/where

As for your warning see this question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文