查找 Git 存储库的名称
在我正在工作的服务器上,我发现我有 Git 支持。厌倦了使用 PuTTY 进行每次提交,我想将该存储库克隆到我的机器并仅在我完成本地工作后才推回。
我如何找到该 git 存储库的名称?在该 Linux 服务器上,我是可以使用 FTP 和 SSH 访问的用户。我的 Web 应用程序在地址 http://linux_server_IP_address/~linux_user
上公开可用。
On a server that I'm working, I find that I have Git support. 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.
how can I find the name of that git repository? On that Linux server I'm a user which has access with FTP and SSH. My web application is public available on the address http://linux_server_IP_address/~linux_user
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
存储库的名称是包含存储库的父文件夹的文件夹名称(因为您在该服务器上工作,所以它是包含 .git 文件夹的文件夹)。但如果有一个 .git 文件夹,它就不是一个裸存储库,然后推送到该存储库是非常糟糕的做法。您应该创建一个裸存储库,然后克隆该存储库并推送到它。
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). But if there's a .git folder, it's not a bare repository, and then push to that repository is very bad practice. You should create a bare repository, and then clone that repository and push to it.
您想知道存储库的路径,而不是名称。
假设您的存储库存储在
$HOME/myrepo
下,您可以通过这种方式克隆它:但是通过 HTTP 克隆,您无法将更改推送到服务器,因此最好使用 SSH 协议:
请参阅 <
git clone
的代码>手册页面有关不同协议的更多信息。请注意,您将无法直接推送到
myrepo
,因为它不是一个裸存储库。要推送到myrepo
上的master
,不得在myrepo
上签出master
。要实现此目的,请转到myrepo
,创建一个临时分支 (git checkout -b nocommit
),然后git push origin master:master
,然后再次git checkout master
。推送到非裸存储库的主题已在此处讨论过多次:
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:But cloning via HTTP, you cannot push back changes to the server, so better use the SSH protocol:
See the
man
page ofgit clone
for more information about the different protocols.Note that you won't be able to push directly to
myrepo
since it's not a bare repository. To push tomaster
onmyrepo
,master
must not be checked out onmyrepo
. To achieve this, go tomyrepo
, create a temporary branch (git checkout -b nocommit
), thengit push origin master:master
and thengit checkout master
again.The topic of pushing into a non-bare repository has been discussed several times here:
这里的人们没有意识到的是,您只是打字
,却看不到主机名。
你必须找到你的 .git 目录(它可能位于你的路径中更靠前的目录中),cd到那里,然后检查配置文件,你需要的整个 URL 就会在那里。
What people here fail to appreciate is that you are just typing
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.