简体   繁体   English

如何在我的服务器上设置 git,并从自身推送?

[英]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.

相关问题 如何在服务器上设置git进行自动提交/推送? - How to setup git on server for auto commit/push? 如何设置自动Git从Push到Bitbucket拉到Ubuntu服务器 - How can I setup automatic Git pull to Ubuntu server from Push to Bitbucket 如何设置我的.git / config以便能够从多个远程存储库推送/拉出? - How can I setup my .git/config to be able to push to / pull from multiple remote repositories? 如何设置git从当前分支中推入和拉出? - How do I setup git to push and pull from the current branch? 我的 git 服务器的 gerrit 设置 - gerrit setup for my git server 如何将“git push”别名为自身+运行脚本? - How to alias "git push" into itself + running a script? 如何在服务器上推送 git - how to git push at server 如何使用git设置Ghost EC2实例,以便可以从本地副本推送更改 - How do I setup Ghost EC2 instance with git so I can push changes from my local copy 如何从我的服务器获取 Git repo url 并从本地开发人员直接推送到它。 终端? - How to get Git repo url from my server and push directly to it from local dev. terminal? 我如何每隔10分钟从客户端的服务器设置一次自动git push? - How do I set up auto git push every 10 minutes from my client's server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM