就在我以为我得到了git checkout -b newbranch - commit/commit/commit - git checkout master - git merge newbranch - git rebase -i master - git push工作流在git中,某些东西爆炸了,我看不出任何理由.
这是一般工作流程,过去对我有用:
# make sure I'm up to date on master:
$ git checkout master
$ git pull # k, no conflicts
# start my new feature
$ git checkout -b FEATURE9 # master @ 2f93e34
Switched to a new branch 'FEATURE9'
Run Code Online (Sandbox Code Playgroud)
...工作,提交,工作,提交,工作,承诺......
$ git commit -a
$ git checkout master
$ git merge FEATURE9
$ git rebase -i master # squash some of the FEATURE9 ugliness
Run Code Online (Sandbox Code Playgroud)
好到目前为止; 现在我期待看到 - 通常看到 - 是这样的:
$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)
Run Code Online (Sandbox Code Playgroud)
但相反,我只看到" 没有提交(工作目录清理) ",没有" 你的分支超过'origin/master'由1提交. ",git pull显示了这种古怪:
$ git pull
From . # unexpected
* branch master -> FETCH_HEAD # unexpected
Already up-to-date. # expected
Run Code Online (Sandbox Code Playgroud)
而git branch -a -v显示了这个:
$ git branch -a -v
FEATURE9 3eaf059 started feature 9
* master 3eaf059 started feature 9
remotes/origin/HEAD -> origin/master
remotes/origin/master 2f93e34 some boring previous commit # should=3eaf059
Run Code Online (Sandbox Code Playgroud)
git branch清楚地显示我当前正在使用*master,并且git log清楚地显示master(本地)是3eaf059,而remotes/origin/HEAD - > remotes/origin/master被卡在了fork中.
理想情况下,我想知道我可能会如何进入这个语义,但我想找到一种方法让我的工作副本再次跟踪远程主控并让两个同步而不会丢失历史记录.谢谢!
(注意:我在一个新目录中重新克隆了repo并手动重新应用了这些更改,一切正常,但我不希望这是标准的解决方法.)
附录:标题上写着"不能推",但没有错误信息.即使git branch -a -v显示本地master位于/ remotes/origin/master之前,我只是获得了"已经是最新"的响应.这是git pull和git remote -v的输出,分别是:
$ git pull
From .
* branch master -> FETCH_HEAD
Already up-to-date.
$ git remote -v
origin git@git.company.com:proj.git (fetch)
origin git@git.company.com:proj.git (push)
Run Code Online (Sandbox Code Playgroud)
附录2:看起来我的本地主人配置为推送到遥控器,但不是从它拉出来.做完之后for remote in 'git branch -r | grep -v master '; do git checkout --track $remote ; done,这就是我所拥有的.看来我只需要让主人再次从遥控器/原点/主人那里拉,不是吗?
$ git remote show origin
* remote origin
Fetch URL: git@git.company.com:proj.git
Push URL: git@git.company.com:proj.git
HEAD branch: master
Remote branches:
experiment_f tracked
master tracked
Local branches configured for 'git pull':
experiment_f merges with remote experiment_f
Local refs configured for 'git push':
experiment_f pushes to experiment_f (up to date)
master pushes to master (local out of date)
Run Code Online (Sandbox Code Playgroud)
当你做了一个git pull,你真的想做一个git push?
由于某种原因,git pull 从你当前的目录"拉",我怀疑你想要从中拉出来remotes/origin/HEAD.
git push origin产生什么输出?
[保罗附录]:这导致我得到了正确答案,所以我接受了.为了弄清楚发生了什么,我们采取了额外的步骤:
# see details of the current config:
$ git config -l
branch.master.remote=. # uh oh, this should point to origin
# to see what it should be ,make a clean clone of the same project
# in a different directory, checkout the master branch and run the
# same command. That showed "branch.master.remote=origin", so...
# then to fix:
$ git config branch.master.remote origin
Run Code Online (Sandbox Code Playgroud)
之后,本地主人再次跟踪遥控器/原点/主人.感谢Peter Farmer提供的线索让我来到这里!