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

2
  • You could also just create a script file named git-pp with the commands as separate lines. They will be executed by bash so they need to mention git though. Commented Jan 31, 2022 at 15:17
  • I actually thought about that approach too, but whant to learn what I'm doing wrong here Commented Jan 31, 2022 at 15:29

1 Answer 1

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" 
Sign up to request clarification or add additional context in comments.

3 Comments

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 ?
@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 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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.