開始,我的樹枝現在默認情況下跟蹤和推動該遠程主,即使我做git push -u origin branch_name
即使我用matching
作爲我push.default
選項。科最近一直跟蹤主
# --------
# STEP 1
# --------
$ git checkout -b my_branch
Branch my_branch set up to track local branch master.
Switched to a new branch 'my_branch'
# --------------------------------------------------------------------------------
# STEP 2: (same behavior BTW with current/upstream/simple)
# --------------------------------------------------------------------------------
$ git config --global push.default matching
# --------
# STEP 3:
# --------
$ git push -u origin my_branch
Counting objects: 8, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 1.16 KiB | 0 bytes/s, done.
Total 8 (delta 7), reused 0 (delta 0)
To XX:YYY/my_repo
62d390c..4e4baa1 my_branch -> master
Branch my_branch set up to track remote branch master from origin.
另外,如果我嘗試STEP 2
下面,我得到一個錯誤:
$ git branch --set-upstream-to=origin/my_branch
error: the requested upstream branch 'origin/my_branch' does not exist
hint:
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint:
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.
我知道我可以手動編輯.git/config
,但爲什麼沒有上述工作?
$ git remote -v
origin XX:YYY/my_repo (fetch)
origin XX:YYY/my_repo (push)
$ git --version
git version 2.9.2
你在推後做了'git fetch'嗎?我會認爲這會創建'origin/my_branch'。 – selfthinker