11

So when using Git in MSVS you can use Fetch to see what incoming commits are waiting on you. Is there a way to set this to happen automatically, or am I forced to click on Fetch every time I think about it?

2
  • 2
    Fundamentally this would be a polling process since git, at least by default, doesn't have push notifications for new commits. Why not just schedule a task to run git fetch every X minutes? Commented Feb 24, 2014 at 21:45
  • 3
    VS Code does this; it would be nice if Visual Studio did as well. Commented Apr 1, 2022 at 16:18

1 Answer 1

2

I got a different but approaching need (I used git-tf on a big project, git tf fetch was taking too long, so I did it in the background to speed up git tf pull command). I poll every 10 minutes, and show the differences visually in the command line. Maybe this can help you:

Git background fetch

I use a powershell script to poll:

function backgroundfetch
{
    while ($true)
    {
        # Get latest
        git fetch;
        # Clear console
        cls;
        # Leave space for progress bar
        for ($i=0; $i -le 6; $i++) {Write-Host;} 
        # Show commit differences between master and origin/master
        git lgori;
        # Show progress bar before next fetch
        for ($i=0; $i -le 1000; $i++)
        {
                Write-Progress -Activity "Sleeping" -status ("{0:0.00} minutes remaining" -f ((1000-$i)/100)) -percentComplete ($i/10);
                Start-Sleep -s 0.6;
        }
    }
}

And 2 git aliases

  • git lg: a pretty git log alias with graph
  • git lgori: to show visually the commit differences between master and origin/master, using the first alias

in .gitconfig:

[alias]
    lg = log --graph --format=format:'%C(yellow)%h%C(reset) %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)- %an%C(reset)%C(bold blue)%d%C(reset)' --abbrev-commit --date=relative
    lgori = !git lg HEAD origin/master --not `git merge-base HEAD origin/master`^
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.