4

I am using git-aware-prompt in my .bash_profile on Ubuntu 15.4 like this:

export GITAWAREPROMPT=~/.bash/git-aware-prompt
source $GITAWAREPROMPT/main.sh

When I am in one of my main repository directories this nicely shows the git branch in my prompt. However, after a few days (I do not restart my box often) it takes a long time after I run a command until the prompt comes back.

Especially when I run commands like git add foo or similar. It takes over a second for the next line of prompt to show up. Even if I open a new terminal window it is still slow.

If I navigate to a different git repo this does not happen. In directories without git it's also fine.

I don't think it's related to the git-aware-prompt, but rather to the repository. There might be some weird cache that I do not know about.

What can I do to make this go fast again?

4
  • Does it happen in a new terminal, too? Whould running git gc in the repo help?
    – choroba
    Aug 18, 2015 at 14:27
  • @choroba: In a new terminal window it happens too. What does git gc do?
    – simbabque
    Aug 18, 2015 at 14:28
  • I ran the garbage collection. That helped a bit. Let's say it gave me a 50% performance boost, but I can still feel the difference between being in a git directory and for example my homedir.
    – simbabque
    Aug 18, 2015 at 14:29
  • 2
    You say you don't think that this is related to git-aware-prompt, and that it doesn't happen in another repository. Do you see this behavior even when you don't source the git-aware-prompt script? If yes, it probably has nothing to do with git-aware-prompt at all. If no, it may be related to a combination of that particular repo and git-aware-prompt (as git-aware-prompt makes a few gitcalls before you are returned to the prompt.) Aug 31, 2015 at 22:21

1 Answer 1

7

You can debug why git is being slow.

There are some ways to improve git performance:

  • Enable git parallel index preload. git config --global core.preloadindex true
  • Minimize the number of files in .git folder. git config --global gc.auto 256
  • Run git garbage collector git gc.
  • Remove untracked files git clean -xf. Use git clean -xfn for a dry-run to check that everything is ok.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .