Ivin
Ivin

Reputation: 4845

git status without default upstream doesnt give full repo comparison information; workaround?

The working repo in my local system has 2 remote repos (stage and live). I want to push to them individually, to stage while developing and to live when code is ready. Hence I can't set a default upstream.

Because of this I dont get the message 'Your branch is behind origin/branch by n commits' when I do git status.

Is there any way to have this message without having to set a default upstream remote/branch? Or at least a command which I could couple with git status to get the same information?

Upvotes: 0

Views: 29

Answers (1)

Andrew C
Andrew C

Reputation: 14903

Nothing directly to do that. You can write up a simple script and alias it (the looping for multiple remotes is untested, but should be close)

myBranch=$(git symbolic-ref --short HEAD)
for upstream in "stage" "live"
do
   ahead=$(git rev-list ${upstream}/${myBranch}..${myBranch} | wc -l)
   behind=$(git rev-list ${myBranch}..${upstream}/${myBranch} | wc -l) 
   # print out whatever you want here 
   echo "${upstream} - ahead ${ahead} behind ${behind}  
done

Upvotes: 1

Related Questions