将git与localhost和VPS一起使用 [英] Using git with localhost and VPS
问题描述
这就是我在VPS上进行测试所要做的:
Thats what I did for testing on VPS:
mkdir git-test && cd git-test
touch test.html
git init
git add test.html
在我的PC本地主机上,我尝试使用TortoiseGIT克隆VPS存储库,但是仅创建了.git文件而没有test.html.我的错误在哪里?
On my PC localhost I tried to clone VPS-repository with TortoiseGIT, but only .git files were created without test.html. Where is my mistake?
我正在尝试设置git,但是完全卡住了.
I'm Trying to set up git, but totally stucked with it.
我的简单方案是:在localhost上编辑Web应用程序的代码,并将更改推送到VPS.没有多余的分支,也没有裸存储库.
My simple scheme is: editing code of web-application on localhost and push changes to VPS. No extra branches and no bare repositories.
谁能一步一步解释我,我该怎么做?编辑文件,然后提交并推送? VPS上的文件会自动更新吗?我需要在VPS上键入任何git命令吗?
Can anyone explain me step by step, how should I do this? Edit file and just commit and push it? Will files on VPS update automatically? Do I need to type any git commands on VPS?
推荐答案
I think you'll need to (re-)read the documentation carefuly, these are the basics of GIT.
基本上,到目前为止,您已经创建了一个空的存储库并添加了1个空文件. 但是...尚未提交此修改(添加文件)!这就是为什么在克隆存储库时它不会出现在您的PC上的原因.
Basically, for now, you've created an empty repository and added 1 empty file. BUT... this modification (add a file) has not been committed yet! That's why it doesn't appear on your PC when you clone the repo.
我对同一个puprose使用GIT:我在本地网络上的raspberryPi上编辑/测试代码,并在验证通过后将更改推送到服务器.这是工作流程.
I'm using GIT for the same puprose : I edit/test code on a raspberryPi on my local network, and push changes to a server when they are validated. Here is the work flow.
系统信息库是在服务器上的/home/me/gitrepos中创建的.这是原始"远程和主"分支.
The repository is created in /home/me/gitrepos on the server. This is the 'origin' remote, and the 'master' branch.
我在PC上和服务器上Web服务器的目录(/var/www/...)中克隆了回购协议.
I cloned the repo on my PC and in the directory on my webserver on the server (/var/www/...).
在我的PC上:编辑代码并将更改推送到存储库:
On my PC : edit code and push change to the repo :
<<Edit code>>
git add ... # if I added new files
git commit -a # commit changes to the branch
git push origin master # commit changes from my local branch to the original branch (the server)
在我的服务器上:从存储库中提取更改并更新Web应用程序
On my server : pull changes from the repo and update the web application
cd /var/www/...
git pull origin master
这篇关于将git与localhost和VPS一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!