Git status in regards to multiple remote repositories

I have a script which emails me a reminder if I’ve forgotten to commit or push some code on each of my 40+ repositories.

With 2 of my projects, I have followed the answers in these posts, where I have set-up “git-push” to push to multiple repositories:

  • Can I add metadata to git commits? Or can I hide some tags in gitk
  • How to create a Git alias with nested commands with parameters?
  • Sourcetree 2.1.2.5 - Shows “Uncommitted changes” yet nothing is pending
  • vbcs.cache/edb.log locked by Visual Studio 2015
  • How to get birds eye view of git tree with just branch names, not individual commits?
  • Is it possible to use winmerge to view git diffs from cygwin?
  • pull/push from multiple remote locations

    git push to multiple repositories simultaneously

    So I have a .git/config file with:

    [core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
    [branch "master"]
        remote = origin
        merge = refs/heads/master
    [remote "origin"]
        url = https://www.example.com/git/project/
        url = git@github.com:username/project.git
    [remote "example"]
        url = https://www.example.com/git/project/
        fetch = +refs/heads/*:refs/remotes/example/*
    [remote "github"]
        url = git@github.com:username/project.git
        fetch = +refs/heads/*:refs/remotes/github/*
    

    This works well when it comes to doing a git push/pull.

    With the script I have used:

    git status --short
    

    But this only shows un-commited changes… even without the “–short” flag, it does not show what normally appears with only 1 remote:

    Your branch is ahead of 'origin/master' by 1 commit.
    

    Trying to run any of the following “diff” commands also doesn’t seem to work… well it does on the first time, but it seems to remember the remote files at the date/time when it was setup, so as you make more changes it compares them against that version in history:

    git diff --name-status "origin";
    git diff --name-status "origin/master";
    git diff --name-status "example/master";
    git diff --name-status "github/master";
    

    Any thoughts? I am fairly new to Git.

  • git filter-branch --msg-filter to reword a pushed commit message
  • Git - How to merge a remote branch into remote master
  • How to fetch change from Git using LibGit2Sharp?
  • How can I know which commit was used when installing a pip package from git?
  • prevent some commit/code to be merged into master
  • Installing Rails Plugin Requires Git?
  • One Solution collect form web for “Git status in regards to multiple remote repositories”

    I believe this method is possibly a bit buggy, as it seems to remember a commit ref for each remote, but this does not get updated when doing a push/pull… so when checking via a diff, its always going to look at the old commit ref for a comparison.

    While its not a solution to this setup, I have gone back to a single remote setup, but edited it so that it has 2 urls… so while the pull only happens from one remote, when I push, it goes to two:

    [core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
    [branch "master"]
        remote = origin
        merge = refs/heads/master
    [remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = https://www.example.com/git/project/
        url = git@github.com:username/project.git
    

    Note: This only works for now, as I’m the only committer.

    Git Baby is a git and github fan, let's start git clone.