简体   繁体   English

如何在服务器上添加和同步我的本地git? 什么是裸回购?

[英]How do i add and sync my local git on server? What is bare repo?

I am using git from a long time but never set it up on server. 我使用git很长一段时间但从未在服务器上设置它。 Refereeing to this Git: move existing repository from PC to server, clone from server 裁判这个Git:将现有存储库从PC移动到服务器,从服务器克隆

I have initiate a bare repo on server but while adding origin in local "git remote add origin server:path/to/repo" i have no idea what to add here. 我已经在服务器上启动了一个裸仓库,但在本地“git remote add origin server:path / to / repo”中添加源代码时我不知道在这里添加什么。 My site is getwalkwel.com and user is getwamld 我的网站是getwalkwel.com,用户是getwamld

Thanks 谢谢

Bare repository in Git is a repository which only contains version control information only in fact this will not have .git sub-directory or any working files. Git中的存储库是一个仅包含版本控制信息的存储库,实际上它不包含.git子目录或任何工作文件。

This kind of repository is helpful when you need to share or divide your work between few people for example in work environment you and your team mates are working on same project and you all need to see changes and all needs to do push to repository in this case this repository is more useful. 当您需要在少数人之间共享或划分您的工作时,这种存储库很有用,例如在工作环境中,您和您的团队成员在同一个项目上工作,并且您都需要查看更改以及所有需要执行此操作的存储库case这个存储库更有用。

You can add the remote repository to local git repo 您可以将远程存储库添加到本地git仓库

$ git remote add origin ssh://myserver.com/var/git/myapp.git

pushing to remote repository: 推送到远程存储库:

to push our local master branch to the origin's master branch. 将我们的本地主分支推送到origin的主分支。 You can do that using the git push <target> <local> command. 您可以使用git push <target> <local>命令执行此操作。

$ git push origin master

click here for more information on how this works 点击此处了解有关其工作原理的更多信息

Origin is the name of a remote which is typically created automatically when you clone a repo from another repo. Origin是远程的名称,通常在您从另一个repo克隆repo时自动创建。 The origin reference in the cloned repo will be created to point back to the repo that was cloned from. 将创建克隆仓库中的原始参考以指回从中克隆的仓库。 In your case, where the bare repo was actually created later from your working repo, you will create origin in your working repo to point back to your new bare repo. 在您的情况下,在您的工作仓库中实际创建裸仓库的情况下,您将在工作仓库中创建原点以指回新的裸仓库。 This is done with: 这完成了:

git remote add origin /barerepo/fullname git remote add origin / barerepo / fullname

If your bare repo is going to line on a different machine, then you need the URL to reach the repo instead of just a file path. 如果您的裸仓库将在另一台机器上排队,那么您需要URL来访问仓库而不仅仅是文件路径。

For instance, you might have myuser@myserver:path/to/repo 例如,你可能有myuser @ myserver:path / to / repo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM