2

For some reason I have to run git gc --prune=now almost every day before I run a git pull so I wanted to create a git pp alias that helps me run those two commands

I added this to the users .gitconfig file

[alias]
    pp = 'gc --prune=now && pull' 

but when I try to run it I get what it seems a sintax error, how do I fix this on windows 10

enter image description here

I have read this

but I dont see my mistake

Mauricio Gracia Gutierrez
  • 10,288
  • 6
  • 68
  • 99

1 Answers1

4

Use a ! at start to indicate that bash has to execute the alias, not git itself.

Then, explicitly call git for your pull command :

git config alias.pp '!git gc --prune=now && git pull'

To use it in the .gitconfig file make sure you use double quotes ""

[alias] 
    pp = "!git gc --prune=now && git pull"
Mauricio Gracia Gutierrez
  • 10,288
  • 6
  • 68
  • 99
Romain Valeri
  • 19,645
  • 3
  • 36
  • 61
  • I have set it to `pp = '!git gc --prune=now && git pull'` as you mention, and still getting the same error, maybe my configuration is wrong ? Do I have to close the git command line everytime I save the .gitconfig ? – Mauricio Gracia Gutierrez Jan 31 '22 at 15:28
  • 2
    @MauricioGraciaGutierrez : the quotes are meant for the command line, not for the config file. Do you have quotes around your alias in your config file ? – LeGEC Jan 31 '22 at 16:07
  • 1
    LeGEC is right, this is probably a confusion because of the first draft of my answer, I should have explicitly used the `git config` command syntax. – Romain Valeri Jan 31 '22 at 16:22