twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
12.63k stars 475 forks source link

'chezmoi update' results in 'no tracking information' error #2360

Closed Ash8888 closed 1 year ago

Ash8888 commented 1 year ago

Current behaviour

%chezmoi update

Error Message: There is no tracking information for the current branch. Please specify which branch you want to rebase against. See git-pull(1) for details.

git pull

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream-to=/ my_dwm

chezmoi: exit status 1

Expected behaviour (correct)

chezmoi pulls changes from my remote repository, and then applys changes to my home directory.

Relevant logs and/or media (optional)

% chezmoi doctor

warning version v2.22.1, built at 2022-09-05T03:33:46Z ok latest-version v2.22.1 ok os-arch linux/amd64 (Arch Linux) ok uname Linux arius 5.19.2-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Wed, 17 Aug 2022 14:28:00 +0000 x86_64 GNU/Linux ok go-version go1.19 (gc) ok executable /usr/bin/chezmoi ok config-file ~/.local/config/chezmoi/chezmoi.yaml, last modified 2022-09-15T12:30:41-04:00 ok source-dir ~/.local/share/chezmoi is a git working tree (clean) ok suspicious-entries no suspicious entries ok working-tree ~/.local/share/chezmoi is a git working tree (clean) ok dest-dir ~ is a directory ok shell-command found /usr/bin/zsh ok shell-args /usr/bin/zsh ok cd-command found /usr/bin/zsh ok cd-args /usr/bin/zsh ok edit-command found /usr/bin/nvim ok edit-args /usr/bin/nvim ok diff-command found ~/.local/bin/vimdiff ok umask 022 ok git-command found ~/.local/bin/git, version 2.37.1 ok merge-command found ~/.local/bin/vimdiff info age-command age not found in $PATH ok gpg-command found /usr/bin/gpg, version 2.2.39 info pinentry-command not set info 1password-command op not found in $PATH info bitwarden-command bw not found in $PATH info gopass-command gopass not found in $PATH info keepassxc-command keepassxc-cli not found in $PATH info keeper-command keeper not found in $PATH info keepassxc-db not set ok lastpass-command found /usr/bin/lpass, version 1.3.3 ok pass-command found /usr/bin/pass, version 1.7.4 info vault-command vault not found in $PATH info secret-command not set

cat chezmoi/.git/config:

[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [submodule] active = . [remote "origin"] url = ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/dotfiles fetch = +refs/heads/:refs/remotes/origin/ [branch "main"] remote = origin merge = refs/heads/main

Other comment (optional)

This had been working until this morning, and I expect something I have done has broken it.

A) Same behavior on seperate computer after I "chezmoi update" B) 'git reset --hard' in chezmoi directory to a commit (well) before the behaviour started.

I was hoping 'chezmoi doctor' would point out the problem, or give me a hint.

Reported by

James H.

Ash8888 commented 1 year ago

Following the instructions in the error message does not correct the issue:

~/.local/share/chezmoi % git pull aws main

On branch main Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

twpayne commented 1 year ago

This problem is due to git commands that you have run which have left your git repo in this state. It is not a problem with chezmoi.

Try searching for git There is no tracking information for the current branch.

Ash8888 commented 1 year ago

Thank you so much for your help, and for Chezmoi - I've quickly become addicted to it.

I've read the link and read more to understand it. I've followed the logic and suggestions there, but the problem persists. In working through those suggestions I've found 2 peculiar things:

A) The "There is no tracking information..." error only appears when I run "chezmoi apply". If I run git commands (fetch/push/pull) directly while in the source path there is no error. I've tried both 'true' and 'false' settings with the "--use-builtin-git" argument.

B) The error message lists 'my_dwm' as the branch, not 'main' as I would expect. Backstory: Chezmoi has been used for a ~month no issue. Right before this error started to occur I was working on a different, unrelated git repo named my_dwm, and I expect that somewhere along the line I ran a git command in the wrong folder - maybe while in "chezmoi cd"? That's my best guess. The /chezmoi-source-dir/.git/config file (above) doesn't include 'my_dwm' anywhere.

$ chezmoi apply

There is no tracking information for the current branch. Please specify which branch you want to rebase against. See git-pull(1) for details.

git pull

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream-to=/ my_dwm

chezmoi: exit status 1

/chezmoi/source/dir$ git branch -a

  • main remotes/origin/HEAD -> origin/main remotes/origin/main

Running the command specified by the error message (and detailed in the link you kindly provided) results in the expected error: /chezmoi/source/dir$ git branch --set-upstream-to=origin/main my_dwm

fatal: branch 'my_dwm' does not exist

Running the command specified by the error message but substituting 'my_dwm' to the existing branch 'main' produces the expected result, but the error persists (only when running cm apply) after this command:

/chezmoi/source/dir$ git branch --set-upstream-to=origin/main main

branch 'main' set up to track 'origin/main'.

Since the error is only occuring when I run cm apply, and not when I run git commands directly from the source dir, getting assistance from the 'git' help resources is going to be difficult.

One last observation I hope is helpful: both of these commands produce the same output: chezmoi --use-builtin-git=true git version

git version 2.37.1

chezmoi --use-builtin-git=false git version

git version 2.37.1

I hope I haven't overlooked anything obvious or simple, and I really appreciate your time. Thank you!

Ash8888 commented 1 year ago

I figured it out...

The error message was being generated by a "type: git-repo" entry that chezmoi was processing from my .chezmoiexternal.yaml file (which pointed to an unrelated repo - "my_dwm"). I had incorrectly assumed that the problem was being reported from the attempt to git pull the chezmoi-source-dir.

If there had been stderr output like: "Error while processing .chezmoiexternal.yaml...." I would of put this together quicker. I spent an embarassing amount of time trying to figure out what was wrong with my chezmoi-source-dir/.git/config file.

Hope this helps some future Google-Fu master, and thank you @twpayne for Chezmoi!

twpayne commented 1 year ago

Great that you figured it out and thank you for the kind words :)

The --debug flag causes chezmoi to print detailed step-by-step information which may be helpful in the future.