0

通常当我这样做时git pullgit status它会自动从远程分支获取并合并数据,并显示可以在该分支上推送的本地提交。

在工作中创建了一个新分支,当我像往常一样做时,我有以下内容:

$ git st
# On branch mybranch-s48
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   src/main/java/com/xxx/batch/bo/utils/DisplayTagUtils.java
#
no changes added to commit (use "git add" and/or "git commit -a")



$ git commit -am "Test git commit"
[mybranch-s48 28813a3] Test git commit
 1 files changed, 2 insertions(+), 0 deletions(-)


$ git st
# On branch mybranch-s48
nothing to commit (working directory clean)


$ git pull
You asked me to pull without telling me which branch you
want to merge with, and 'branch.mybranch-s48.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.

If you often merge with the same branch, you may want to
use something like the following in your configuration file:

    [branch "mybranch-s48"]
    remote = <nickname>
    merge = <remote-ref>

    [remote "<nickname>"]
    url = <url>
    fetch = <refspec>

通常“拉”不需要任何东西,状态会告诉我我有 1 个提交提交。

我仍然可以使用git pull origin mybranch-s48or git push origin mybranch-s48

此分支不在列表中,但在执行时Local branches configured for 'git pull':仅在列表中Local refs configured for 'git push':git remote show origin

有人能帮助我吗

4

1 回答 1

1

尝试设置上游分支:

git branch mybranch-s48 --set-upstream origin/mybranch-s48

通常,当您检出存在于远程但不在本地存储库中的分支时,会制作一个本地副本以“跟踪”远程分支。如果您以其他方式创建了本地分支,并且 Git 还不知道它应该跟踪远程分支,那么您需要使用--set-upstream.

于 2012-11-27T14:48:40.880 回答