【问题标题】:What is the correct way to connect my package to GitHub after installing it via composer install通过 composer install 安装包后将包连接到 GitHub 的正确方法是什么
【发布时间】:2017-04-16 15:35:33
【问题描述】:

我在 Laravel 安装的 vendor 文件夹中创建了一个 composer 包。

然后我创建了一个 GitHub 存储库并在包中初始化了一个 git 实例,以对我在 GitHub 上的更改进行版本控制。

最后,我通过 composer 在同一个 Laravel 安装中安装了我的包。 (我在composer.json文件中添加了我的包名和版本,然后执行composer install

现在,在同一个项目中,我希望能够对代码进行更多更改,然后将其添加到存储库中。

我对我的文件进行了更改。但后来我做了git add . 我得到了以下错误

fatal: Not a git repository (or any of the parent directories): .git

我认为当我安装软件包时,它删除了 .git 文件,这就是我收到此错误的原因。

在不搞砸任何事情的情况下,将现有代码连接到 GitHub 以便推送新更改的最佳方式是什么?

更新

这是位于 /vedors/package/.git/config 中的配置文件的内容

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    sshCommand = ssh -oHostKeyAlgorithms=+ssh-dss
[remote "origin"]
    url = https://github.com/username/crud-builder.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    pushurl = git@github.com:username/crud-builder.git
[branch "master"]
    remote = origin
    merge = refs/heads/master
[remote "composer"]
    url = https://github.com/username/crud-builder.git
    fetch = +refs/heads/*:refs/remotes/composer/*

【问题讨论】:

    标签: php git laravel github composer-php


    【解决方案1】:

    1 - 在供应商中删除您的包文件夹

    rm -rf vendor/yourname/yourpackagename
    

    2 - 使用源重新安装它

    composer update --prefer-sources
    

    这样做的结果是vendor/yourname/yourpackagename最终会成为一个git仓库,你应该可以再次提交和推送。

    【讨论】:

    • prefer-sources 是做什么的?我是否需要更改我的作曲家文件,以便它知道我也想连接哪个包?
    • 您无需更改任何其他内容。它基本上使用git clone而不是下载来下载包。
    • 所以当我做git push 我得到以下错误Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
    • 检查您的 /vendor/name/package/.git/config 文件。如果你有使用 SSH 或 git@ 的远程,你可以更改为 https 版本并使用你的登录名和密码登录
    • 我不太确定我应该在那里寻找什么。我用我的配置文件的内容更新了我的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-20
    • 1970-01-01
    • 2016-11-14
    • 1970-01-01
    • 2021-06-28
    • 1970-01-01
    • 2019-05-21
    相关资源
    最近更新 更多