我想构建一个本地Git存储库。我正在使用配置文件。我收到一个错误

发布于 2024-10-28 04:29:45 字数 505 浏览 0 评论 0原文

我的配置文件是

[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

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请持续率性 2024-11-04 04:29:45

如果您查看 git clone 文档中有关 URL 的部分,您将看到它说:

[user@]host.xz:path/to/repo.git

... 相当于:

ssh://[user@]host.xz/~/path/to/repo.git

由于 [user@] 表明 user@ 是可选的,它试图解释 /Users/ voloda2/safe/tut:tut.git 作为通过 SSH 的存储库的 scp 样式规范。 (假设主机名为 /Users/voloda2/safe/tut,路径为 ~/tut.git

看起来存储库应该是 < code>/Users/voloda2/safe/tut/,但是,请尝试将 URL 更改为以下之一:

/Users/voloda2/safe/tut/
file:///Users/voloda2/safe/tut/

您可以通过以下方式执行此操作:

git config remote.origin.url /Users/voloda2/safe/tut/

If you look at the section on URLs in the git clone documentation, you'll see that it says that:

[user@]host.xz:path/to/repo.git

... is equivalent to:

ssh://[user@]host.xz/~/path/to/repo.git

Since the [user@] indicates that user@ is optional, it's trying to interpret /Users/voloda2/safe/tut:tut.git as an scp-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:

/Users/voloda2/safe/tut/
file:///Users/voloda2/safe/tut/

You can do that with:

git config remote.origin.url /Users/voloda2/safe/tut/
筑梦 2024-11-04 04:29:45

基本上,如果您不想与同事共享文件,则不需要使用某些远程存储库。

通常的本地工作流程是:

git init 在项目文件夹的根目录

git add . 添加所有文件

git commit -m "initial commit"

进行一些更改

git add ChangedFile.cgit add .

git commit -m "commit changes"

就这样。您的更改保存在本地存储库中

PS 有一个本地远程测试的步骤。

mkdir /tmp/test.git
cd /tmp/test.git
git init --bare /tmp/test.git
git push /tmp/test.git +master

之后您可以添加 /tmp/test.git 作为远程存储库

git remote add origin /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 folder

git add . add all your files

git commit -m "initial commit"

make some change

git add ChangedFile.c or git add .

git commit -m "commit changes"

that's all. your changes are saved in local repository

PS There is a steps with local remote test.

mkdir /tmp/test.git
cd /tmp/test.git
git init --bare /tmp/test.git
git push /tmp/test.git +master

after that you can add /tmp/test.git as remote repository

git remote add origin /tmp/test.git
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文