git 分支在提交后未显示为在原点之前

git branch not showing as ahead of origin after commit

我有一个 git 功能分支,它是我从开发分支创建的:

git checkout -b CRM-feature-branch develop

然后我将它推送到远程:

git push origin HEAD

当我在本地提交到这个分支并执行 git status 它不显示我的分支在前面。

这是因为我用 git push origin HEAD 而不是 git push origin -u CRM-feature-branch 在原点上创建了分支吗?

简而言之:。如果您不使用 --set-upstream(或简称 -u),那么您的本地 git 存储库不知道您所在分支的 "remote counterpart"。您仍然可以使用

解决此问题
git push -u origin CRM-feature-branch

git branch --set-upstream CRM-feature-branch origin/CRM-feature-branch

进一步阅读:Why do I need to do `--set-upstream` all the time?