Recent repositories
Hello !
I'm using lazygit for few months now and I love it !
I have a question regarding recent repositories, how does it work ? At the moment the list contains my main repository and old ones that I have not used since few weeks, but repositories I used yersterday do not appear anymore, why is that ?
Is there a way to configure lazygit to always show a list of repositories ? To make sure they do not disappear ? I did not found anything like that in config file but I may have missed it.
Thanks !
The recent repositories list should contain the list of all repositories the user has opened lazygit in. If you don't open lazygit in a repo, it won't appear in that list.
The cache is just a text file you can find in the folder that lazygit --cd returns, there's a state.yml that holds the state.
The folder returned by lazygit --cd only contains config.yaml for me. I found a file state.yaml in ~/.local/state/lazygit, but I guess it is not "good practice" to update it here ? I tried to move it in my .config but it does not seems to work.
Is there a documentation for this file ?
The folder returned by lazygit --cd only contains config.yaml for me.
Okay, I might have been mistaken about the --cd flag then, my bad.
but I guess it is not "good practice" to update it here
It's generally not something users should edit manually so I don't think it's documented anywhere.
So what you're saying is that you run lazygit in a new git folder and the recentrepos in that state.yml doesn't update?
So what you're saying is that you run
lazygitin a newgitfolder and therecentreposin thatstate.ymldoesn't update?
When I open a new repo, it is correctly added in state.yaml. But sometimes, for reasons I do not understand, the list of recent repositories is update so that some repositories are removed.
For example, from yersterday/today update of my recent repositores :
Recent repositories yersterday
- dir1
- dir2
- dir3
Open dir4 and dir5, recent repositories :
- dir1
- dir2
- dir3
- dir4
- dir5
Today when I open my recent repositories, there are only
- dir1
- dir2
- dir3
dir4 and dir5, which are the most recent ones, were removed, but older repo are still present.
And I don't understand why my most recent repositories where deleted.
Sorry if that's not clear
One reason I can see that might explain this is when you have multiple instances of lazygit running at the same time: they will overwrite each other's state.
For example:
- start with an empty list of repos
- open lazygit in dir1 (state.yml now contains dir1)
- open another lazygit instance in dir2 (state.yml now contains dir1 and dir2)
- make some change to the app state in the first lazygit instance (for example, show or hide the command log)
- this will remove dir2 again from state.yml
It seems that we should be able to fix this by reloading state.yml whenever its modification date changed, similar to how I'm reloading the config file in #3787.
Mhmm, I'm not sure I had more than 1 instance of lazygit at the time, but I'll be careful from now on.
Another cause might be that if repositories do not exist anymore they are removed from recent repo ? If a repositories is moved somewhere else (path in state.yaml does not exist anymore) then moved back, depending on when lazygit checks if it exists, it might delete the path ?
If a repositories is moved somewhere else (path in state.yaml does not exist anymore)
lazygit will remove invalid paths from state.yml on launch, so that would explain why they're gone.
Adding them again requires lazygit to be launched from the directory again, same as it was required the first time around.
Ok so that explains why they disappear then, it was obvious but I did not think about it enough I guess.
It would be nice if it could keep the paths but only display valid ones, so that adding the repositories back to the right path would also make it appear in recent repositories again.
Thanks for helping me to figure this out !
Is moving repos around something you do often? If so, why? 🤔
I'm developing inside a software which has external plugins, which have their own repositories.
When I update this software, it can break external plugins. in order to compile/test them, the easiest way is to move these plugins inside the main software, in src/plugins (which contains internal plugins as well). Once the plugins are fixed, I move them out, because I do not want to compile / test them every time that I build/test the main software.
Alrighty then, I'd definitely suggest to explore the possibility of symlinks, so that you don't have to move the plugins here and there but just link and unlink. I'm not sure if it's applicable, but might be worth a shot.
I never thought about this... you're a genius ! It works perfectly fine ! Thanks
Still not clear to me where state.yml are found.
@Ridermansb according to the docs, on MacOS it should be in ~/Library/Application\ Support/lazygit/?
Is it a way to run lazygit with the list of repos right after launch? I didn't find such flag. It would be perfect to have a flag what opens a recent repo.
When I run it from a random dir it shows the question about creating a new repo:
~/Downloads ❯ lazygit
Not in a git repository. Create a new git repository? (y/N):
@Riddlerrr Put notARepository: skip in your lazygit config file, this will skip the prompt and open the recent repos menu right away. (Unless you call lazygit from inside a repo, then that one will always be opened.)
@stefanhaller Thanks for the lightning-fast reply 🚀
I made a small command what reads get the recent repo and opens lazygit with the path:
lazygit -p $(grep -A 1 "recentrepos:" ~/.local/state/lazygit/state.yml | tail -1 | sed 's/^[[:space:]]*-[[:space:]]*//')
I hope it will help someone who also want just open recent repo or open lazygit from app launcher