2014年11月20日 星期四

解決git status無法顯示有多少commit尚未push的問題

如果你有注意,可以發現有時候git status會回給你蠻有用的資訊,像是:""Your branch is ahead of 'origin/master' by 1 commit";有些則沒有。

要解決這個問題可以參考以下的方式:

以下是可以正常顯示額外資訊的git repository中,其.git/config當中的某一段
[remote "origin"]
	url = https://github.com/RyanChouTw/PicStream.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master

以下則是相同git repository,但是不會顯示額外資訊
[remote "origin"]
	url = https://github.com/RyanChouTw/PicStream.git
	fetch = +refs/heads/*:refs/remotes/origin/*

可以發現,有問題的版本就是少了一段,你可以自己手動修改.git/config,也可以透過以下的命令解決喔。
$ git config branch.master.remote origin
$ git config branch.master.merge refs/heads/master

以上提供參考。

沒有留言: