我想构建一个本地Git存储库。我正在使用配置文件。我收到一个错误
我的配置文件是
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = /Users/voloda2/safe/tut:tut.git
[branch "master"]
remote = origin
merge = refs/heads/master
我收到错误: git push ssh:无法解析主机名/Users/voloda2/safe/tut:提供节点名或服务名,或未知
致命:远程端意外挂起
My config file is
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = /Users/voloda2/safe/tut:tut.git
[branch "master"]
remote = origin
merge = refs/heads/master
I got an error: git push
ssh: Could not resolve hostname /Users/voloda2/safe/tut: nodename nor servname provided, or not known
fatal: The remote end hung up unexpectedly
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您查看 git clone 文档中有关 URL 的部分,您将看到它说:
... 相当于:
由于
[user@]
表明user@
是可选的,它试图解释/Users/ voloda2/safe/tut:tut.git
作为通过 SSH 的存储库的scp
样式规范。 (假设主机名为/Users/voloda2/safe/tut
,路径为~/tut.git
)看起来存储库应该是 < code>/Users/voloda2/safe/tut/,但是,请尝试将 URL 更改为以下之一:
您可以通过以下方式执行此操作:
If you look at the section on URLs in the git clone documentation, you'll see that it says that:
... is equivalent to:
Since the
[user@]
indicates thatuser@
is optional, it's trying to interpret/Users/voloda2/safe/tut:tut.git
as anscp
-style specification for a repository over SSH. (The host is assumed to be called/Users/voloda2/safe/tut
, with the path~/tut.git
)It looks as if the repository should just be
/Users/voloda2/safe/tut/
, however, so try changing the URL to either of:You can do that with:
基本上,如果您不想与同事共享文件,则不需要使用某些远程存储库。
通常的本地工作流程是:
git init
在项目文件夹的根目录git add .
添加所有文件进行一些更改
git add ChangedFile.c
或git add .
就这样。您的更改保存在本地存储库中
PS 有一个本地远程测试的步骤。
之后您可以添加 /tmp/test.git 作为远程存储库
Basically you're don't need to use some remote repo if you're don't want to share your files with co-workers.
Usual local workflow is:
git init
in root of your project foldergit add .
add all your filesmake some change
git add ChangedFile.c
orgit add .
that's all. your changes are saved in local repository
PS There is a steps with local remote test.
after that you can add /tmp/test.git as remote repository