我不是git master,但是我已經和它一起工作了一段時間了,并且有幾個不同的項目。當然,在每個項目中,從那時git clone [repository]起,我始終可以git pull,并且只要沒有特別的變化,我就可以始終如此。最近,我不得不還原到上一個分支,并使用進行了此操作git checkout 4f82a29。當我再次準備拉動時,我發現必須將分支設置回master。現在,我不能使用直線git pull,而是必須指定git pull origin master,這很煩人,并向我表明我不完全了解發生了什么。發生了什么變化,哪些使我無法在git pull不指定原點大師的情況下進行平直比賽?如何更改它?更新:-bash-3.1$ cat config[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true[branch "master"][remote "origin"] url = [email protected]:user/project.git fetch = refs/heads/*:refs/remotes/origin/*更新2:明確地說,我知道我的原始方法可能不正確,但是我需要修復此存儲庫,以便可以git pull再次使用。目前,git pull導致:-bash-3.1$ git pullYou asked me to pull without telling me which branch youwant to merge with, and 'branch.master.merge' inyour configuration file does not tell me either. Pleasename which branch you want to merge on the command line andtry again (e.g. 'git pull ').See git-pull(1) for details on the refspec.If you often merge with the same branch, you may want toconfigure the following variables in your configurationfile: branch.master.remote = branch.master.merge = remote..url = remote..fetch = See git-config(1) for details.我可以說出git pull要合并的分支,它可以正常工作,但git pull不能像原來的分支那樣工作git checkout。
3 回答

慕哥6287543
TA貢獻1831條經驗 獲得超10個贊
在下[branch "master"],嘗試將以下內容添加到倉庫的Git配置文件(.git/config):
[branch "master"]
remote = origin
merge = refs/heads/master
這告訴Git 2件事:
當您在master分支上時,默認的遙控器是origin。
在git pullmaster分支上使用(未指定任何遠程和分支)時,請使用默認的remote(來源)并合并來自remote master分支的更改。
我不確定為什么會從您的配置中刪除此設置。您可能也必須遵循其他人發布的建議,但這可能有用(或至少有幫助)。
如果您不想手動編輯配置文件,則可以使用命令行工具:
$ git config branch.master.remote origin
$ git config branch.master.merge refs/heads/master
- 3 回答
- 0 關注
- 610 瀏覽
添加回答
舉報
0/150
提交
取消