Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Visual Studio to Fetch incoming commits automatically

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?

like image 404
Heath Carroll Avatar asked Feb 24 '14 21:02

Heath Carroll


People also ask

How do I see incoming commits?

More generically, if you're not on the master branch, use git log .. @{u} to see the commits that are on the upstream remote tracking branch of your current local branch. @sschuberth This should be the answer.

How do I get the latest code from git in Visual Studio 2022?

To do that in Visual Studio, first make sure to fetch and get the latest updates from your remote repository Git > Fetch. Then right click on the remote branch you would like to review and select Checkout Tip Commit.

How do I pull a specific commit in Visual Studio?

Still in Solution Explorer, right click on the file and choose "View History". In the history window, find the commit for the version you want to test with. Right click on it and choose "Open". This pops up a temporary file with the contents of the desired version.


1 Answers

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`^
like image 108
Guillaume Collic Avatar answered Nov 15 '22 04:11

Guillaume Collic