Daily Update error - GIT

Yes, I meant remote

You have completely re-initialized the git repository… To fix it:

git remote add origin https://github.com/librenms/librenms.git
 - or origin exists -
git remote origin set-url https://github.com/librenms/librenms.git
git fetch origin
git checkout master
git reset --hard origin/master

And whatever you did before don’t do that again. And for others not in the exact situation as the OP, don’t run the above commands.

Hi Murrant,

No luck:

git remote add origin https://github.com/librenms/librenms.git
fatal: remote origin already exists.

git remote origin set-url https://github.com/librenms/librenms.git
error: Unknown subcommand: origin

Of course I will not touch that. Didn’t change anythin by hand until get git first error.

Thanks!

I swapped two of the arguments around:

git remote set-url origin https://github.com/librenms/librenms.git

Thanks Murrant, git command run ok.
Then ./daily.sh failed, as it is showed below.

-bash-4.2$ git remote set-url origin https://github.com/librenms/librenms.git

-bash-4.2$ ./daily.sh
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
warning: ignoring broken ref refs/heads/master.
error: pathspec 'master' did not match any file(s) known to git.
fatal: Needed a single revision
Updating to latest codebase                        FAIL
fatal: No such ref: HEAD
fatal: No such ref: HEAD
You are not currently on a branch. Please specify which
branch you want to merge with. See git-pull(1) for details.

    git pull <remote> <branch>
fatal: Needed a single revision
Updating Composer packages                         OK
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Updated from unset to                              OK
Updating SQL-Schema                                OK
Updating submodules                                OK
Cleaning up DB                                     OK
Fetching notifications                             OK
Caching PeeringDB data                             OK

You didn’t do the other commands after that one:

git fetch origin
git checkout master
git reset

Well, “git checkout master” doesn’t worked.

-bash-4.2$ git fetch origin
-bash-4.2$ git checkout master
warning: ignoring broken ref refs/heads/master.
error: pathspec 'master' did not match any file(s) known to git.
-bash-4.2$ git reset

Try git checkout -t origin/master

-bash-4.2$  git checkout -t origin/master
error: The following untracked working tree files would be overwritten by checkout:
        .codeclimate.yml
        .editorconfig
        .env.example
        .github/ISSUE_TEMPLATE.md
        .github/ISSUE_TEMPLATE/New-Device.md
        .github/PULL_REQUEST_TEMPLATE.md
        .github/ci-reporter.yml
        .github/label-actions.yml
        .github/lock.yml
        .github/no-response.yml
        .github/stale.yml
        .gitignore
        .mention-bot
        .scrutinizer.yml
        .travis.yml
        AUTHORS.md
        CHANGELOG.md
        CODE_OF_CONDUCT.md
        CONTRIBUTING.md
        LICENSE.txt
        LibreNMS/Alert/AlertData.php
        LibreNMS/Alert/AlertUtil.php
        LibreNMS/Alert/Template.php
        LibreNMS/Alert/Transport.php
        LibreNMS/Alert/Transport/Alerta.php
        LibreNMS/Alert/Transport/Alertmanager.php
        LibreNMS/Alert/Transport/Api.php
        LibreNMS/Alert/Transport/Boxcar.php
        LibreNMS/Alert/Transport/Canopsis.php
        LibreNMS/Alert/Transport/Ciscospark.php
        LibreNMS/Alert/Transport/Clickatell.php
        LibreNMS/Alert/Transport/Discord.php
        LibreNMS/Alert/Transport/Dummy.php
        LibreNMS/Alert/Transport/Elasticsearch.php
        LibreNMS/Alert/Transport/Gitlab.php
        LibreNMS/Alert/Transport/Hipchat.php
        LibreNMS/Alert/Transport/Hue.php
        LibreNMS/Alert/Transport/Irc.php
        LibreNMS/Alert/Transport/Jira.php
        LibreNMS/Alert/Transport/Kayako.php
        LibreNMS/Alert/Transport/Mail.php
        LibreNMS/Alert/Transport/Mattermost.php
        LibreNMS/Alert/Transport/Msteams.php
        LibreNMS/Alert/Transport/Nagios.php
        LibreNMS/Alert/Transport/Opsgenie.php
        LibreNMS/Alert/Transport/Osticket.php
        LibreNMS/Alert/Transport/Pagerduty.php
        LibreNMS/Alert/Transport/Playsms.php
        LibreNMS/Alert/Transport/Pushbullet.php
        LibreNMS/Alert/Transport/Pushover.php
        LibreNMS/Alert/Transport/Rocket.php
        LibreNMS/Alert/Transport/Slack.php
        LibreNMS/Alert/Transport/Smseagle.php
        LibreNMS/Alert/Transport/Smsfeedback.php
        LibreNMS/Alert/Transport/Syslog.php
        LibreNMS/Alert/Transport/Telegram.php
        LibreNMS/Alert/Transport/Twilio.php
        LibreNMS/Alert/Transport/Victorops.php
        LibreNMS/Alerting/QueryBuilderFilter.php
        LibreNMS/Alerting/QueryBuilderParser.php
        LibreNMS/Authentication/ADAuthorizationAuthorizer.php
        LibreNMS/Authentication/ActiveDirectoryAuthorizer.php
        LibreNMS/Authentication/ActiveDirectoryCommon.php
        LibreNMS/Authentication/AuthorizerBase.php
        LibreNMS/Authentication/HttpAuthAuthorizer.php
        LibreNMS/Authentication/LdapAuthorizationAuthorizer.php
        LibreNMS/Authentication/LdapAuthorizer.php
        LibreNMS/Authentication/LdapSessionCache.php
        LibreNMS/Authentication/LegacyAuth.php
        LibreNMS/Authentication/MysqlAuthorizer.php
        LibreNMS/Authentication/RadiusAuthorizer.php
        LibreNMS/Authentication/SSOAuthorizer.php
        LibreNMS/Authentication/TwoFactor.php
        LibreNMS/Authentication/UserProxy.php
        LibreNMS/Component.php
        LibreNMS/ComposerHelper.php
        LibreNMS/Config.php
        LibreNMS/DB/Eloquent.php
        LibreNMS/DB/Schema.php
        LibreNMS/Device/Processor.php
        LibreNMS/Device/Sensor.php
        LibreNMS/Device/WirelessSensor.php
        LibreNMS/Device/YamlDiscovery.php
        LibreNMS/Exceptions/ApiException.php
        LibreNMS/Exceptions/AuthenticationException.php
        LibreNMS/Exceptions/DatabaseConnectException.php
        LibreNMS/Exceptions/FileExistsException.php
        LibreNMS/Exceptions/FileNotFoundException.php
        LibreNMS/Exceptions/HostExistsException.php
        LibreNMS/Exceptions/HostIpExistsException.php
        LibreNMS/Exceptions/HostUnreachableException.php
        LibreNMS/Exceptions/HostUnreachablePingException.php
        LibreNMS/Exceptions/HostUnreachableSnmpException.php
        LibreNMS/Exceptions/InvalidIpException.php
        LibreNMS/Exceptions/InvalidModuleException.php
        LibreNMS/Exceptions/InvalidPortAssocModeException.php
        LibreNMS/Exceptions/InvalidRrdTypeException.php
        LibreNMS/Exceptions/JsonAppBlankJsonException.php
        LibreNMS/Exceptions/JsonAppException.php
        LibreNMS/Exceptions/JsonAppExtendErroredException.php
        LibreNMS/Exceptions/JsonAppMissingKeysException.php
        LibreNMS/Exceptions/JsonAppParsingFailedException.php
        LibreNMS/Exceptions/JsonAppPollingFailedException.php
        LibreNMS/Exceptions/JsonAppWrongVersionException.php
        LibreNMS/Exceptions/LockException.php
        LibreNMS/Exceptions/SnmpVersionUnsupportedException.php
        LibreNMS/IRCBot.php
        LibreNMS/Interfaces/Alert/Transport.php
        LibreNMS/Interface
Aborting

git pull origin master?

-bash-4.2$ git pull origin master
fatal: No such ref: HEAD
From https://github.com/librenms/librenms
 * branch            master     -> FETCH_HEAD
error: unable to resolve reference HEAD: No such file or directory
fatal: Cannot lock the ref 'HEAD'.
git gc --prune=now
git remote prune origin
git pull

Run out of disk space on this server previously? Your git is corrupted :frowning: We should be able to repair it.

Run git remote -v too

-bash-4.2$ git gc --prune=now
error: bad ref for refs/heads/master
error: bad ref for refs/heads/master
Counting objects: 139266, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (41574/41574), done.
Writing objects: 100% (139266/139266), done.
Total 139266 (delta 95715), reused 138603 (delta 95292)
error: bad ref for refs/heads/master
Checking connectivity: 139266, done.

-bash-4.2$ git remote prune origin
Pruning origin
URL: https://github.com/librenms/librenms.git
 * [pruned] origin/kkrumm1-patch-2

-bash-4.2$ git pull
fatal: No such ref: HEAD
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 24 (delta 12), reused 11 (delta 9), pack-reused 4
Unpacking objects: 100% (24/24), done.
From https://github.com/librenms/librenms
   fffd468..b571482  master     -> origin/master
fatal: No such ref: HEAD
You are not currently on a branch. Please specify which
branch you want to merge with. See git-pull(1) for details.

    git pull <remote> <branch>

-bash-4.2$ git pull  origin master
fatal: No such ref: HEAD
From https://github.com/librenms/librenms
 * branch            master     -> FETCH_HEAD
error: unable to resolve reference HEAD: No such file or directory
fatal: Cannot lock the ref 'HEAD'.

-bash-4.2$ git remote -v
origin  https://github.com/librenms/librenms.git (fetch)
origin  https://github.com/librenms/librenms.git (push)

rm .git/refs/heads/master
git reset

Hmm I wonder if that last one was a good idea or not.
git fetch
echo ref: refs/heads/master >.git/HEAD
git checkout master
git pull

We might have to do echo 2eac72d34b2246255b260840db948bf8a4ed3316 > .git/refs/heads/master

That worked

echo 2eac72d34b2246255b260840db948bf8a4ed3316 &gt; .git/refs/heads/master

Then the git checkout master run ok.

D       tests/tests.py
D       validate.php
D       webpack.mix.js
Already on 'master'
Your branch is behind 'origin/master' by 4 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

-bash-4.2$ git pull
Updating 2eac72d..b571482
error: Your local changes to the following files would be overwritten by merge:
        LibreNMS/Authentication/ADAuthorizationAuthorizer.php
        LibreNMS/Authentication/ActiveDirectoryAuthorizer.php
        LibreNMS/Authentication/LdapAuthorizationAuthorizer.php
        LibreNMS/Authentication/LdapAuthorizer.php
        LibreNMS/Exceptions/DatabaseConnectException.php
        README.md
        app/Checks.php
        app/Console/Commands/AddUserCommand.php
        app/Exceptions/Handler.php
        app/Http/Controllers/Table/FdbTablesController.php
        app/Models/PortsFdb.php
        daily.php
        daily.sh
        doc/Support/Configuration.md
        doc/Support/Discovery Support.md
        doc/Support/Features.md
        html/pages/device/port/fdb.inc.php
        html/pages/device/ports/fdb.inc.php
        html/pages/search/fdb.inc.php
        includes/defaults.inc.php
        includes/discovery/fdb-table.inc.php
        misc/db_schema.yaml
        tests/data/edgecos_es3510ma.json
        tests/module_tables.yaml
Please, commit your changes or stash them before you can merge.
error: The following untracked working tree files would be overwritten by merge:
        database/migrations/2019_02_10_220000_add_dates_to_fdb.php
Please move or remove them before you can merge.
Aborting

Great, now you just need to run ./scripts/github-remove -d and ./daily.sh (You should run ./validate.php too)

Excellent Murrant!
Thank you very much!

1 Like