简体   繁体   English

查找Git存储库的名称

[英]Finding the name of the Git repository

On a server that I'm working, I find that I have Git support. 在我正在工作的服务器上,我发现我有Git支持。 Tired by going with PuTTY to do each commit, I'll like to clone that repository to my machine and push back only when I've done my local work. 厌倦了与PuTTY一起执行每个提交,我想将该存储库克隆到我的计算机上,并且仅在完成本地工作后才回推。

how can I find the name of that git repository? 如何找到该git存储库的名称? On that Linux server I'm a user which has access with FTP and SSH. 在该Linux服务器上,我是具有FTP和SSH访问权限的用户。 My web application is public available on the address http://linux_server_IP_address/~linux_user . 我的Web应用程序在地址http://linux_server_IP_address/~linux_user上公开可用。

The name of the repository is the folder name of the parent folder which contains the repository (since you do your work on that server, it's the folder, which contains the .git folder). 存储库的名称是包含存储库的父文件夹的文件夹名称(由于您在该服务器上进行工作,因此是包含.git文件夹的文件夹)。 But if there's a .git folder, it's not a bare repository, and then push to that repository is very bad practice. 但是,如果有一个.git文件夹,则它不是裸存储库,然后推送到该存储库是非常不好的做法。 You should create a bare repository, and then clone that repository and push to it. 您应该创建一个裸存储库,然后克隆该存储库并将其推送到该存储库。

You want to know the path to your repository, not the name . 您想知道存储库的路径 ,而不是名称

Assuming that your repository is stored under $HOME/myrepo , you could clone it that way: 假设您的存储库存储在$HOME/myrepo ,则可以通过以下方式克隆它:

git clone http://linux_server_ip/~linux_user/myrepo

But cloning via HTTP, you cannot push back changes to the server, so better use the SSH protocol: 但是通过HTTP克隆后,您无法将更改推回服务器,因此最好使用SSH协议:

git clone ssh://linux_user@linux_server_ip/myrepo

See the man page of git clone for more information about the different protocols. 有关不同协议的更多信息,请参见git cloneman页。

Note that you won't be able to push directly to myrepo since it's not a bare repository. 请注意,由于它不是裸存储库,因此无法直接将其推送到myrepo To push to master on myrepo , master must not be checked out on myrepo . 推送到mastermyrepomaster不得在签出myrepo To achieve this, go to myrepo , create a temporary branch ( git checkout -b nocommit ), then git push origin master:master and then git checkout master again. 为此,转到myrepo ,创建一个临时分支( git checkout -b nocommit ),然后git push origin master:master ,然后再次git checkout master

The topic of pushing into a non-bare repository has been discussed several times here: 推送到非裸存储库的主题已在此处多次讨论:

What people here fail to appreciate is that you are just typing 这里的人无法欣赏的是您只是在打字

git <command>

and you never see a hostname. 而且您永远都看不到主机名。

You have to find your .git directory (it may be in a directory further up in your path), cd there and then check the config file, the whole URL you need will be there. 您必须找到您的.git目录(它可能位于路径中更远的目录中),在其中cd进行检查,然后检查配置文件,您所需的整个URL将在其中。

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

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