事情是這樣,我們有一個分支,名為 eReceipt,目前有兩個同仁同時再同一個分支上進行開發。
同仁A說,他已經把新的提交 push 到遠端了。
同仁B使用 remote update 確實更新了遠端分支資訊。
但使用 status 卻沒有看到有新提交的資訊。
同仁B就到另一臺主機,使用另一個測試環境,做一樣的動作,結果卻是可以正常顯示有新提交的資訊。
如此,同仁B就確定這是自己電腦測試環境的 git 問題而已。
同仁B若直接使用 pull 是可以順利拉回新提交,只是希望在 status 可以看到相關資訊,然後決定要做什麼動作。
最後,同仁B懷疑是自己的 git 在這個分支的跟蹤設定可能跑掉了。
因此,重新設定這個分支需要追蹤遠端分支的狀態才行。
指令如下:
$ git branch --set-upstream-to=origin/eReceipt eReceipt
Branch 'eReceipt' set up to track remote branch 'eReceipt' from 'origin'.
$ git status
On branch eReceipt
Your branch is behind 'origin/eReceipt' by 1 commit, and can be fast-forwarded.
(use "git pull" to update your local branch)
nothing to commit, working tree clean
成功了,只是個小問題。不過,不知道為什麼會突然發生不追蹤的狀況。