[英]How to setup git on my server, and push from itself?
My boss asked me to install git and create a repo on the company server, to keep it all in house and not in third party companies.我的老板让我安装 git 并在公司服务器上创建一个 repo,以将其全部保存在内部而不是第三方公司。 But damn, this request is too much to me...
但是该死的,这个要求对我来说太过分了……
The problem is: I have limited access to the server, already have a project running and need to push from another folder in it.问题是:我对服务器的访问权限有限,已经有一个项目正在运行,需要从其中的另一个文件夹推送。 It means that I only have access to
public_html
(but the path to this folder is known), which have other 2 folders.这意味着我只能访问
public_html
(但该文件夹的路径是已知的),它还有其他 2 个文件夹。 One is the current LIVE version, and the other is the development version.一个是当前的 LIVE 版本,另一个是开发版本。
I can create more folders and edit everything inside them, but cannot cd
to an upper directory or any other folder, besides those two, that it wasn't me who created).我可以创建更多文件夹并编辑其中的所有内容,但不能
cd
到上层目录或任何其他文件夹,除了这两个,不是我创建的)。
Since we have a web editor, we edit everything in the server and any save we do, already goes to it.由于我们有一个网络编辑器,我们编辑服务器中的所有内容,我们所做的任何保存都已经进入它。 Thus, we don't use local files or anything like that.
因此,我们不使用本地文件或类似的东西。
I have only used GitHub to store commits and versions so I'm a bit lost when it comes to git itself.我只使用 GitHub 来存储提交和版本,所以当谈到 git 本身时我有点迷茫。 All the tutorials and explanations I have read says to use
/tmp
or /var
folders and/or create and remove users, which isn't in my reach.我读过的所有教程和解释都说要使用
/tmp
或/var
文件夹和/或创建和删除用户,这不在我的范围内。
What I need to do is: knowing all of this restrictions, how do I setup the environment to commit and push from folder A of the server to folder B (supposing that B is the master and A a clone)?我需要做的是:知道所有这些限制,我如何设置环境以从服务器的文件夹 A 提交和推送到文件夹 B(假设 B 是主服务器,A 是克隆)?
I have done this many times for testing purposes.出于测试目的,我已经多次这样做了。
Go to folder B and make a: git init --bare
转到文件夹 B 并创建一个:
git init --bare
This will create multiple files for git purpose.这将为 git 目的创建多个文件。 This is now your main repository.
现在这是您的主要存储库。
Go to folder A and make a:转到文件夹 A 并制作:
git init
git remote add origin PATH/TO/FOLDER/B
and thats all.就这样。
Now you can do: git add .
现在你可以做:
git add .
, git commit -m 'messsage'
, git push/pull origin master
from folder A. ,
git commit -m 'messsage'
, git push/pull origin master
from folder A.
Your folder B will receive all pushes.您的文件夹 B 将收到所有推送。 You can test it making a
git log
in folder B您可以在文件夹 B 中创建一个
git log
来测试它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.