如何检查远程存储库是否已更改,我需要拉?
现在我使用这个简单的脚本:
git pull --dry-run | grep -q -v 'Already up-to-date.' && changed=1
Run Code Online (Sandbox Code Playgroud)
但它相当沉重.
有没有更好的办法?理想的解决方案是检查所有远程分支,并返回已更改分支的名称和每个分支的新提交数.
每个git用户都习惯于此:
> git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Run Code Online (Sandbox Code Playgroud)
然而,最近我开始使用两个遥控器而不是一个(heroku和github,非常标准的情况,我认为),它开始让我烦恼只能在git status输出中看到1个原点.
我怎么能添加其他遥控器所以我会看到这样的东西?
> git status
On branch master
Your branch is up-to-date with 'origin/master'.
Your branch is up-to-date with 'heroku/master'.
nothing to commit, working directory clean
Run Code Online (Sandbox Code Playgroud)
(这个问题与heroku或github无关,这只是一个方便的例子.)